Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDX-10449 new contribute form #6530

Open
wants to merge 45 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
810ba70
HDX-10450 change sections order
ccataalin Jan 23, 2025
8924ba4
HDX-10452 extend bem components
ccataalin Feb 5, 2025
d380eed
HDX-10452 improve bem components
ccataalin Feb 5, 2025
20342ce
HDX-10452 UI/styling changes
ccataalin Feb 5, 2025
924f6c0
HDX-10452 fix tests
ccataalin Feb 5, 2025
32b23ee
HDX-10452 fix contribute anchors
ccataalin Feb 12, 2025
0e20847
HDX-10452 fix file upload issue
ccataalin Feb 12, 2025
052bb5d
HDX-10452 bem component for resource format
ccataalin Feb 13, 2025
6f302fd
HDX-10452 show overwrite button
ccataalin Feb 13, 2025
31264b7
HDX-10452 update texts
ccataalin Feb 13, 2025
545de21
HDX-10451 update contribute form page
ccataalin Feb 14, 2025
0f52192
HDX-10452 fix file upload area spacing
ccataalin Feb 14, 2025
c89ede8
HDX-10452 update resource onFieldEdit selector to match BEM class
ccataalin Feb 14, 2025
dd06f56
HDX-10452 prevent submitting pii resources & improve upload type switch
ccataalin Feb 14, 2025
35735c4
HDX-104555 make data preview section visible to everyone
ccataalin Feb 14, 2025
94b4820
HDX-10454 sorting/reordering logic for resources
ccataalin Feb 18, 2025
e771475
HDX-10453 add option for label tooltip
ccataalin Feb 18, 2025
4524b6c
HDX-10453 style time period field, improve datepicker (jqueryui updat…
ccataalin Feb 18, 2025
d1b31a6
HDX-10454 style sorting arrows
ccataalin Feb 18, 2025
ec12148
HDX-10456 fix read more about licenses link
ccataalin Feb 19, 2025
2dffc04
HDX-10456 move drop file component
ccataalin Feb 19, 2025
865f8e7
HDX-10456 change title placeholder, add space on top, update label to…
ccataalin Feb 19, 2025
818762b
HDX-10451 improve contribute iframe, fix checkbox id & data preview f…
ccataalin Feb 19, 2025
0e41dd6
HDX-10560 update error messages
ccataalin Feb 21, 2025
65105b8
HDX-10456 fix spacing between fields in the resource section
ccataalin Feb 21, 2025
8b8bc45
HDX-10456 make tags red
ccataalin Feb 21, 2025
eefadf4
HDX-10456 prevent adding empty options
ccataalin Feb 21, 2025
0e44071
HDX-10456 small bug fixes
ccataalin Feb 21, 2025
b6b9fc1
HDX-10456 fix data preview
ccataalin Feb 21, 2025
e51e231
HDX-10456 fix tests
ccataalin Feb 21, 2025
e8dd30b
HDX-10560 extend customized error messages and display errors for dat…
ccataalin Feb 21, 2025
e0a5f97
HDX-10456 make "tags you'd like to request" field free-text
ccataalin Feb 25, 2025
3c7de35
HDX-10456 add back the spinner
ccataalin Feb 25, 2025
30ca238
HDX-10456 remove contribute iframe x button
ccataalin Feb 25, 2025
e55af48
HDX-10456 make sure the select2 ajax results are unique
ccataalin Feb 25, 2025
319b672
HDX-10456 set max-width for private datasets popup
ccataalin Feb 25, 2025
df645f2
HDX-10456 update title placeholder
ccataalin Feb 25, 2025
7f1cab9
HDX-10456 remove data viz gray header
ccataalin Feb 25, 2025
8382fde
HDX-10456 remove x icon for org field
ccataalin Feb 25, 2025
86acfa8
HDX-10456 add down arrow for select2 multi field
ccataalin Feb 26, 2025
daea7d6
HDX-10456 fix drag-drop-ghost component
ccataalin Feb 26, 2025
5a5187d
HDX-10549 update naming tips text
ccataalin Feb 26, 2025
f571d40
HDX-10456 hide error block when empty
ccataalin Feb 26, 2025
9fb2aaa
HDX-10456 fix bem checkbox id
ccataalin Feb 27, 2025
695180a
HDX-10456 fix freshness field
ccataalin Feb 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ def detect_format(key, data, errors, context):
if file_format:
data[key] = file_format
return file_format
err_message = "We couldn't determine your file type. If it is a compressed format (zip, etc), please \
indicate the primary format of the data files inside compressed file."
err_message = "Please specify the file format."
errors[key].append(_(err_message))
raise df.StopOnError()

Expand Down Expand Up @@ -861,3 +860,11 @@ def hdx_update_last_modified_if_url_changed(key: FlattenKey, data: FlattenDataDi
prev_url_value = prev_resource_dict.get('url')
if prev_url_value != url_value:
data[key] = datetime.datetime.utcnow()

def hdx_comma_separated_validator(value):
if isinstance(value, list):
return ','.join(value)
elif isinstance(value, str):
return value
else:
raise tk.ValidationError('Value must be a string or a list.')
1 change: 1 addition & 0 deletions ckanext-hdx_package/ckanext/hdx_package/helpers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ def generate_mandatory_fields():
# 'title': dataset_name,
'license_id': 'cc-by',
'owner_org': selected_org.get('id'),
'owner_org_name': selected_org.get('name'),
'dataset_source': selected_org.get('title'),
'maintainer': user,
'subnational': 1,
Expand Down
7 changes: 5 additions & 2 deletions ckanext-hdx_package/ckanext/hdx_package/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ def get_validators(self):
'hdx_keep_unless_allow_resource_in_hapi_field':
vd.hdx_package_keep_prev_value_unless_field_in_context_wrapper(
'allow_resource_in_hapi_field', resource_level=True),
'hdx_comma_separated_validator': vd.hdx_comma_separated_validator,
}

def get_auth_functions(self):
Expand Down Expand Up @@ -659,8 +660,10 @@ def _update_with_requestdata_modify_package_schema(self, schema):
schema.update(requestdata_schema)

schema.update({
'field_names': [tk.get_validator('not_empty'), tk.get_converter('convert_to_extras')],
'file_types': [tk.get_validator('not_empty'), tk.get_converter('convert_to_extras')],
'field_names': [tk.get_validator('not_empty'), tk.get_validator('hdx_comma_separated_validator'),
tk.get_converter('convert_to_extras')],
'file_types': [tk.get_validator('not_empty'), tk.get_validator('hdx_comma_separated_validator'),
tk.get_converter('convert_to_extras')],
'num_of_rows': [tk.get_validator('ignore_missing'), tk.get_validator('is_positive_integer'),
tk.get_converter('convert_to_extras')],
'data_update_frequency': [tk.get_validator('ignore_missing'), tk.get_converter('convert_to_extras')],
Expand Down
49 changes: 48 additions & 1 deletion ckanext-hdx_package/ckanext/hdx_package/views/contribute_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ def validate(package_type=None):
for key, val in err_dict.items()}
for idx, err_dict in enumerate(e.error_dict.get('resources', ())) if err_dict
}
return _prepare_and_render(save_type=save_type, data=data_dict, errors=e.error_dict,

customized_errors = _customize_error_messages(e.error_dict)

return _prepare_and_render(save_type=save_type, data=data_dict, errors=customized_errors,
error_summary=error_summary)
except Exception as e:
ex_msg = e.message if hasattr(e, 'message') else str(e)
Expand All @@ -225,6 +228,50 @@ def _prepare_data_for_saving(context, package_type):
return data_dict


def _customize_error_messages(errors):
custom_messages = {
'name': {
'Missing value': 'Please provide a URL for your dataset.',
'That URL is already in use.': 'Please provide a different URL for your dataset as this already exists.'
},
'notes': {
'Missing value': 'A description of your dataset is required.'
},
'dataset_source': {
'Missing value': 'Please specify the source of your data.'
},
'maintainer': {
'Missing value': 'Please choose an individual maintainer for this dataset.'
},
'data_update_frequency': {
'Missing value': 'Please select how often this dataset is expected to be updated.'
},
'groups_list': {
'Missing value': 'Please specify the location(s) covered by this dataset.'
},
'methodology': {
'Missing value': 'Please choose a methodology for your dataset.'
},
'owner_org': {
'Missing value': 'Please select the organisation responsible for this dataset.'
},
'dataset_date': {
'Missing value': 'Please specify the time period covered by your data.'
},
}

customized_errors = {}
for field, error_list in errors.items():
customized_errors[field] = []
for error in error_list:
if field in custom_messages and error in custom_messages[field]:
customized_errors[field].append(custom_messages[field][error])
else:
customized_errors[field].append(error)

return customized_errors


hdx_contribute.add_url_rule(u'/new', view_func=new, methods=[u'GET', u'POST'])
hdx_contribute.add_url_rule(u'/edit/<id>', view_func=edit, methods=[u'GET', u'POST'])
hdx_contribute.add_url_rule(u'/validate', view_func=validate, methods=[u'POST'])
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
.checkbox-field__label.form-check-label {
vertical-align: middle;
vertical-align: sub;
color: #000;
font-size: 16px;
}
.checkbox-field__required {
color: #F2645A;
font-weight: 600;
}
.checkbox-field__tooltip {
cursor: pointer;
font-size: 13px;
margin-left: 2px;
color: #4B5563;
display: inline-flex;
}
.checkbox-field__input.form-check-input {
height: 20px;
width: 20px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@
.form-button__btn.btn-primary:hover {
background-color: #0162DD;
}
.form-button__btn.btn-danger {
padding: 10px;
border-radius: 6px;
font-weight: 400;
font-family: 'Gotham-Bold', sans-serif;
border-color: #F38077;
background-color: #F38077;
}
.form-button__btn.btn-danger:hover {
background-color: #F2645A;
}
.form-button__btn.btn-link {
text-decoration: none;
font-family: 'Inter', sans-serif;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@
.heading h3 {
font-size: 30px;
}
.heading h6 {
font-size: 20px;
}
.heading__title {
color: #0F172A;
line-height: 1.2;
font-family: 'Gotham-Bold', sans-serif;
font-weight: 400;
}
.heading__required {
color: #F2645A;
font-weight: 600;
font-size: 1rem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.bem-hr {
opacity: 1;
}
.bem-hr_color-black {
color: #000;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
background-color: #EDF6FD;
padding: 22px;
}
.info-box_type-compact {
padding: 12px 16px;
}
.info-box_type-rounded {
border-radius: 4px;
}
.info-box__icon {
font-size: 22px;
color: #0162DD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
font-size: 16px;
margin-bottom: 8px;
}
.input-field__label-guideline {
color: #4B5563;
font-weight: 400;
font-size: 14px;
margin-bottom: 8px;
line-height: 22px;
}
.input-field__required {
color: #F2645A;
font-weight: 600;
Expand Down Expand Up @@ -46,6 +53,14 @@
border-color: #D1D5DB;
background-color: #FFF;
}
.input-field__input-group-text_position_left {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.input-field__input-group-text_position_right {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.input-field__input-group-text_state_clickable:hover {
cursor: pointer;
color: #4B5563;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
font-size: 18px;
}
.paragraph__text_font_size-small {
font-size: 14px;
}
.paragraph__text_font_size-extra-small {
font-size: 12px;
}
.paragraph__text_font-weight-bold {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.radio-field__input:focus {
box-shadow: none;
}
.radio-field__input:checked {
background-color: #000;
border-color: #000;
}
.radio-field__label {
color: #4B5563;
font-weight: 600;
font-size: 16px;
margin-bottom: 8px;
}
.radio-field__label-guideline {
color: #4B5563;
font-weight: 400;
font-size: 14px;
margin-bottom: 8px;
line-height: 22px;
}
.radio-field__required {
color: #F2645A;
font-weight: 600;
}
.radio-field__feedback-message {
font-size: 14px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,26 @@
text-rendering: auto;
-webkit-font-smoothing: antialiased;
}
.input-placeholder::placeholder {
color: #6c757d;
font-family: 'Inter', sans-serif;
font-size: 1rem;
font-weight: 500;
line-height: 30px;
}
.select2-field__label {
color: #4B5563;
font-weight: 600;
font-size: 16px;
margin-bottom: 8px;
}
.select2-field__label-guideline {
color: #4B5563;
font-weight: 400;
font-size: 14px;
margin-bottom: 8px;
line-height: 22px;
}
.select2-field__required {
color: #F2645A;
font-weight: 600;
Expand All @@ -22,16 +36,60 @@
.select2-field .select2-container .select2-selection {
box-shadow: none;
}
.select2-field .select2-container .select2-selection.select2--large .select2-selection__clear {
background-color: #FFF;
}
.select2-field .select2-container .select2-selection.select2--large .select2-selection__rendered {
font-weight: 500;
line-height: 30px;
font-size: 1rem;
font-family: 'Inter', sans-serif;
}
.select2-field .select2-container .select2-selection.select2--large .select2-selection__rendered .select2-selection__choice {
padding: 0 0.75rem;
border-radius: 0;
background: #888;
color: #FFF;
text-transform: uppercase;
font-family: 'Source Sans Pro', sans-serif;
font-weight: 600;
font-size: 15px;
letter-spacing: 0.5px;
border: 0;
}
.select2-field .select2-container .select2-selection.select2--large .select2-selection__rendered .select2-selection__choice__remove {
width: 0.75rem;
height: 0.75rem;
margin-right: 0.35rem;
padding: 0.25rem;
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23ffffff'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e");
background-position-x: 50%;
background-position-y: center;
background-size: 1rem;
background-repeat: no-repeat;
background-color: transparent;
}
.select2-field .select2-container .select2-selection.select2--large .select2-selection__rendered .select2-selection__choice__remove:hover {
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%234B5563'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e");
}
.select2-field .select2-container .select2-selection.select2--large .select2-selection__rendered .select2-selection__placeholder {
font-weight: 500;
line-height: 30px;
}
.select2-field .select2-container .select2-selection--multiple {
padding-right: 36px;
}
.select2-field .select2-container .select2-selection--multiple::after {
position: absolute;
right: 12px;
top: calc(50% - 6px);
font: var(--fa-font-solid);
font-size: 0.75rem;
content: '\f078';
}
.select2-field .select2-container .select2-dropdown .select2-search input {
background: none;
}
.select2-field .select2-container .select2-dropdown .select2-search::after {
font: var(--fa-font-solid);
content: '\f002';
Expand All @@ -51,3 +109,17 @@
.select2-field .select2-container .select2-dropdown .select2-search .select2-search__field:focus {
box-shadow: none;
}
.select2-field .select2-container .select2-search__field {
font-family: 'Inter', sans-serif;
font-size: 1rem;
}
.select2-field .select2-container .select2-search__field::placeholder {
color: #6c757d;
font-family: 'Inter', sans-serif;
font-size: 1rem;
font-weight: 500;
line-height: 30px;
}
.select2-field_color-orange .select2-container .select2-selection.select2--large .select2-selection__rendered .select2-selection__choice {
background: #F2645A;
}
Loading
Loading