MCPcopy Create free account
hub / github.com/bajrangCoder/setu / render

Method render

src/components/form_data_editor.rs:204–441  ·  view source on GitHub ↗
(&mut self, _window: &mut Window, cx: &mut Context<Self>)

Source from the content-addressed store, hash-verified

202 pub fn get_fields(&self, cx: &App) -> Vec<FormDataField> {
203 if self.bulk_mode {
204 return self
205 .bulk_editor
206 .as_ref()
207 .map(|editor| {
208 parse_bulk_kv(&editor.read(cx).text().to_string())
209 .into_iter()
210 .map(|entry| FormDataField {
211 key: entry.key,
212 value: entry.value,
213 enabled: entry.enabled,
214 })
215 .collect()
216 })
217 .unwrap_or_default();
218 }
219
220 self.rows
221 .iter()
222 .map(|row| FormDataField {
223 key: row.key_input.read(cx).text().to_string(),
224 value: row.value_input.read(cx).text().to_string(),
225 enabled: row.enabled,
226 })
227 .collect()
228 }
229
230 pub fn build_encoded_string(&self, cx: &App) -> String {
231 self.get_fields(cx)
232 .into_iter()
233 .filter(|f| f.enabled && !f.key.is_empty())
234 .map(|f| {
235 format!(
236 "{}={}",
237 urlencoding::encode(&f.key),
238 urlencoding::encode(&f.value)
239 )
240 })
241 .collect::<Vec<_>>()
242 .join("&")
243 }
244
245 pub fn get_form_data(&self, cx: &App) -> std::collections::HashMap<String, String> {
246 let mut map = std::collections::HashMap::new();
247 for field in self.get_fields(cx) {
248 if field.enabled && !field.key.is_empty() {
249 map.insert(field.key, field.value);
250 }
251 }
252 map
253 }
254
255 pub fn set_from_string(&mut self, content: &str, window: &mut Window, cx: &mut Context<Self>) {
256 self.rows.clear();
257
258 for pair in content.split('&') {
259 if pair.is_empty() {
260 continue;
261 }

Callers

nothing calls this directly

Calls 11

childMethod · 0.80
idMethod · 0.80
textMethod · 0.80
on_clickMethod · 0.45
clear_allMethod · 0.45
add_rowMethod · 0.45
move_rowMethod · 0.45
newMethod · 0.45
toggle_rowMethod · 0.45
remove_rowMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected