Defect #728

MD edit form : Save forces to fill 'required' fields, should only force when validate

Added by Blatti Yves over 4 years ago. Updated about 3 years ago.

Status:ClosedStart date:
Priority:UrgentDue date:
Assignee:-% Done:

100%

Category:CATALOG
Target version:4.2.0
Affected version:4.1.0

Description

I may be wrong, but when we save a metadata, we should not be forced to fill all required (mandatory) fields. This should only happen when we validate the metadata.
Can someone confirm that this is the correct behavior?

If we have a look at line 102 here:
source:/tags/4.1.0/joomla/easysdi/com_easysdi_core/src/administrator/libraries/easysdi/catalog/editMetadata.js#L102

We'll see:

           switch (actions[1]) {
                case 'cancel':

                    break;
                case 'save':
                case 'saveAndContinue':
                    js('.required').removeClass('required').addClass('remove-required');
                    if (document.formvalidator.isValid(form)) {
                        Joomla.submitform(task, form);
                    } else {
                        js('.remove-required').removeClass('remove-required').addClass('required');
                        js('html, body').animate({scrollTop: 0}, 'slow');
                    }
                    return true;
                    break;
                case 'control':

It looks like the objective was to temporary disable required fields.
But with validator enabled, fields with 'required' have more html5ish attributes added (by JS):
  • required="required"
  • aria-required="true"

So the the fields remain mandatory
(may be a side effect of #677)

I propose to extend the script like this:

            switch (actions[1]) {
                case 'cancel':

                    break;
                case 'save':
                case 'saveAndContinue':
                    js('.required').removeClass('required').addClass('remove-required').removeAttr('required').removeAttr('aria-required');
                    if (document.formvalidator.isValid(form)) {
                        Joomla.submitform(task, form);
                    } else {
                        js('.remove-required').removeClass('remove-required').addClass('required').attr('aria-required', 'true').attr('required', 'required');
                        js('html, body').animate({scrollTop: 0}, 'slow');
                    }
                    return true;
                    break;
                case 'control':

If confirmed, I'll commit in my sandbox.
Thanks for your replies.

History

#1 Updated by Magoni Bruno over 4 years ago

  • Target version set to Unplanned

I would like to say that it depends in which status the metadata is.
If metadata is already published, I guess that metadata responsible is able to update content of a metadata after clicking on "Save". So in this case, metadata must be also "validated" not to break content rules... (may be in such case, should we rename "Save" to "Update ?)

I don't know if such problem comes from #677 resolution but such fix needs to be tested against all metadata action through complete lifecycle version ("working progress" to "published" state).

#2 Updated by Magoni Bruno over 4 years ago

  • Target version deleted (Unplanned)

#3 Updated by Magoni Bruno about 4 years ago

  • Assignee set to Blatti Yves
  • Priority changed from Normal to Urgent

Hi Yves,

Have you already work on it regarding my last note ?

We need your confirmation to organize such fix!

Thanks a lot,
Bruno

#4 Updated by Battaglia Marc about 4 years ago

  • Assignee changed from Blatti Yves to Battaglia Marc
  • Target version set to 156

This has been corrected. Package in 4.2.0-beta-5

#5 Updated by Battaglia Marc about 4 years ago

  • Assignee changed from Battaglia Marc to Magoni Bruno

#6 Updated by Magoni Bruno about 4 years ago

  • Status changed from New to Affected

#7 Updated by Magoni Bruno about 4 years ago

  • Status changed from Affected to Resolved
  • Assignee changed from Magoni Bruno to Battaglia Marc

Thanks Marc :-)

#8 Updated by Magoni Bruno about 4 years ago

  • % Done changed from 0 to 100

#9 Updated by Battaglia Marc about 4 years ago

  • Status changed from Resolved to Closed

#10 Updated by Magoni Bruno almost 4 years ago

  • Target version changed from 156 to 4.2.0

#11 Updated by Van Hoecke Hélène about 3 years ago

  • Assignee deleted (Battaglia Marc)

Also available in: Atom PDF