TArgeted communities and adaptations support multiple entries
Browse files- sdc_view.py +37 -19
sdc_view.py
CHANGED
@@ -243,16 +243,16 @@ def render_sdc():
|
|
243 |
)
|
244 |
|
245 |
def init_state(key):
|
246 |
-
if key not in st.session_state:
|
247 |
-
st.session_state[key] = []
|
248 |
|
249 |
def add_text_area(key):
|
250 |
init_state(key)
|
251 |
-
st.session_state[key].append("")
|
252 |
|
253 |
def remove_text_area(index,key):
|
254 |
-
if key in st.session_state and 0 <= index < len(st.session_state[key]):
|
255 |
-
st.session_state[key].pop(index)
|
256 |
st.rerun() # Rerun to update the interface
|
257 |
|
258 |
|
@@ -364,7 +364,7 @@ def render_sdc():
|
|
364 |
add_text_area(key)
|
365 |
# Loop over the array and create a text area with a remove button for each element
|
366 |
|
367 |
-
for idx, processes in enumerate(st.session_state[key]):
|
368 |
# Create two columns: one for the text area, one for the remove button
|
369 |
col1, col2 = st.columns([6, 1])
|
370 |
with col1:
|
@@ -381,9 +381,10 @@ def render_sdc():
|
|
381 |
add_text_area(key)
|
382 |
# Loop over the array and create a text area with a remove button for each element
|
383 |
|
384 |
-
for idx, text in enumerate(st.session_state[key]):
|
385 |
# Create two columns: one for the text area, one for the remove button
|
386 |
with st.container(border=True):
|
|
|
387 |
col1, col2 = st.columns([3, 2])
|
388 |
with col1:
|
389 |
cached_text_input("Body name", f"{key}_{idx}_name", "The name of id of the body")
|
@@ -393,7 +394,7 @@ def render_sdc():
|
|
393 |
with col2:
|
394 |
cached_multiple_radio(f"{key}_{idx}_type", ['funders', 'directors', 'administrators', 'other'], f"Body role type" )
|
395 |
if st.button("Remove", key=f"{key}_remove_{idx}"):
|
396 |
-
remove_text_area(idx,f"{key}
|
397 |
|
398 |
|
399 |
with st.expander("If needed provide detailed information about the organizations or individuals involved in the governance", expanded=False):
|
@@ -410,7 +411,7 @@ def render_sdc():
|
|
410 |
with usageContext:
|
411 |
colr, coll = st.columns([1, 1])
|
412 |
with colr:
|
413 |
-
key = "
|
414 |
cached_text_area("Social context",f"{key}_description", "Description of the usage and social context of the app")
|
415 |
with coll:
|
416 |
cached_multiple_radio(f"{key}_countries",ISO3166,"The countries where the app is intended to be deployed and used")
|
@@ -421,15 +422,31 @@ def render_sdc():
|
|
421 |
])
|
422 |
with targetCommunities:
|
423 |
keyTarget = key+"_targetCommunity"
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
428 |
with adaptations:
|
429 |
keyAdapt = key+"_adaptation"
|
430 |
-
|
431 |
-
|
432 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
433 |
with participants:
|
434 |
# Participants
|
435 |
st.write("Add the different teams participating the software project")
|
@@ -439,9 +456,10 @@ def render_sdc():
|
|
439 |
add_text_area(key)
|
440 |
# Loop over the array and create a text area with a remove button for each element
|
441 |
|
442 |
-
for idx, text in enumerate(st.session_state[key]):
|
443 |
# Create two columns: one for the text area, one for the remove button
|
444 |
with st.container(border=True):
|
|
|
445 |
col1, col2 = st.columns([2, 2])
|
446 |
with col1:
|
447 |
cached_text_input("Team name", f"{key}_{idx}_name", "The name of id of the team")
|
@@ -466,12 +484,12 @@ def render_sdc():
|
|
466 |
# Provide a download button
|
467 |
st.download_button(
|
468 |
label="Download Markdown",
|
469 |
-
data=
|
470 |
file_name="SoftareDiveristyCard.md",
|
471 |
mime="text/markdown"
|
472 |
)
|
473 |
st.text("Preview:")
|
474 |
-
st.markdown(generate_markdown(unflattenedJson), unsafe_allow_html=True)
|
475 |
with jsonTab:
|
476 |
|
477 |
# Convert the session state to a JSON string
|
|
|
243 |
)
|
244 |
|
245 |
def init_state(key):
|
246 |
+
if key not in st.session_state.form_data:
|
247 |
+
st.session_state.form_data[key] = []
|
248 |
|
249 |
def add_text_area(key):
|
250 |
init_state(key)
|
251 |
+
st.session_state.form_data[key].append("")
|
252 |
|
253 |
def remove_text_area(index,key):
|
254 |
+
if key in st.session_state.form_data and 0 <= index < len(st.session_state.form_data[key]):
|
255 |
+
st.session_state.form_data[key].pop(index)
|
256 |
st.rerun() # Rerun to update the interface
|
257 |
|
258 |
|
|
|
364 |
add_text_area(key)
|
365 |
# Loop over the array and create a text area with a remove button for each element
|
366 |
|
367 |
+
for idx, processes in enumerate(st.session_state.form_data[key]):
|
368 |
# Create two columns: one for the text area, one for the remove button
|
369 |
col1, col2 = st.columns([6, 1])
|
370 |
with col1:
|
|
|
381 |
add_text_area(key)
|
382 |
# Loop over the array and create a text area with a remove button for each element
|
383 |
|
384 |
+
for idx, text in enumerate(st.session_state.form_data[key]):
|
385 |
# Create two columns: one for the text area, one for the remove button
|
386 |
with st.container(border=True):
|
387 |
+
st.subheader(f"Governance body:", divider="gray")
|
388 |
col1, col2 = st.columns([3, 2])
|
389 |
with col1:
|
390 |
cached_text_input("Body name", f"{key}_{idx}_name", "The name of id of the body")
|
|
|
394 |
with col2:
|
395 |
cached_multiple_radio(f"{key}_{idx}_type", ['funders', 'directors', 'administrators', 'other'], f"Body role type" )
|
396 |
if st.button("Remove", key=f"{key}_remove_{idx}"):
|
397 |
+
remove_text_area(idx,f"{key}")
|
398 |
|
399 |
|
400 |
with st.expander("If needed provide detailed information about the organizations or individuals involved in the governance", expanded=False):
|
|
|
411 |
with usageContext:
|
412 |
colr, coll = st.columns([1, 1])
|
413 |
with colr:
|
414 |
+
key = "usageContext"
|
415 |
cached_text_area("Social context",f"{key}_description", "Description of the usage and social context of the app")
|
416 |
with coll:
|
417 |
cached_multiple_radio(f"{key}_countries",ISO3166,"The countries where the app is intended to be deployed and used")
|
|
|
422 |
])
|
423 |
with targetCommunities:
|
424 |
keyTarget = key+"_targetCommunity"
|
425 |
+
init_state(keyTarget)
|
426 |
+
if st.button("Add target communities"):
|
427 |
+
add_text_area(keyTarget)
|
428 |
+
# Loop over the array and create a text area with a remove button for each element
|
429 |
+
|
430 |
+
for idx, text in enumerate(st.session_state.form_data[keyTarget]):
|
431 |
+
st.subheader(f"Target community:", divider="gray")
|
432 |
+
cached_text_input("Name",f"{keyTarget}_{idx}_name", "Name or ID of the target community")
|
433 |
+
cached_text_area("Description",f"{keyTarget}_{idx}_description", "Description of the target community")
|
434 |
+
group(f"{keyTarget}_{idx}")
|
435 |
+
if st.button("Remove", key=f"{keyTarget}_remove_{idx}"):
|
436 |
+
remove_text_area(idx,keyTarget)
|
437 |
+
# Adaptations
|
438 |
with adaptations:
|
439 |
keyAdapt = key+"_adaptation"
|
440 |
+
init_state(keyAdapt)
|
441 |
+
if st.button("Add adaptations"):
|
442 |
+
add_text_area(keyAdapt)
|
443 |
+
for idx, text in enumerate(st.session_state.form_data[keyAdapt]):
|
444 |
+
st.subheader(f"Adaptation:", divider="gray")
|
445 |
+
cached_text_input("Name",f"{keyAdapt}_{idx}_name", "Name or ID of the adaptation")
|
446 |
+
cached_text_area("Description",f"{keyAdapt}_{idx}_description", "Description of the adaptation")
|
447 |
+
if st.button("Remove", key=f"{keyAdapt}_remove_{idx}"):
|
448 |
+
remove_text_area(idx,keyAdapt)
|
449 |
+
|
450 |
with participants:
|
451 |
# Participants
|
452 |
st.write("Add the different teams participating the software project")
|
|
|
456 |
add_text_area(key)
|
457 |
# Loop over the array and create a text area with a remove button for each element
|
458 |
|
459 |
+
for idx, text in enumerate(st.session_state.form_data[key]):
|
460 |
# Create two columns: one for the text area, one for the remove button
|
461 |
with st.container(border=True):
|
462 |
+
st.subheader(f"Participant team:", divider="gray")
|
463 |
col1, col2 = st.columns([2, 2])
|
464 |
with col1:
|
465 |
cached_text_input("Team name", f"{key}_{idx}_name", "The name of id of the team")
|
|
|
484 |
# Provide a download button
|
485 |
st.download_button(
|
486 |
label="Download Markdown",
|
487 |
+
data='',
|
488 |
file_name="SoftareDiveristyCard.md",
|
489 |
mime="text/markdown"
|
490 |
)
|
491 |
st.text("Preview:")
|
492 |
+
#st.markdown(generate_markdown(unflattenedJson), unsafe_allow_html=True)
|
493 |
with jsonTab:
|
494 |
|
495 |
# Convert the session state to a JSON string
|