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

Improved ZMSMetaobjManager GUI #156

Merged
merged 11 commits into from
Jul 14, 2023
Merged

Improved ZMSMetaobjManager GUI #156

merged 11 commits into from
Jul 14, 2023

Conversation

drfho
Copy link
Contributor

@drfho drfho commented Jul 12, 2023

Hello @zmsdev
Intermediate saving on adding new attributes to the content model may not match the user's expectations. Actually it is not very fast. So the ZMI should alllow just a "final" Saving. The code proposal works with JS-cloning of the "add"-row. The cloned TR-element is used as a template that is changed by JS so that it can work like the "old" rows. Thus the backend code can handle it.

ZMS5_INSERT_ROW

About the JS Code:
The crucial point is that the JS-cloning has to be done inside the click-event function and the added TR needs an unique ID, to get it selected in the DOM.
A cloning in advance, means outside the funktion, generates one global object which on button-click will instanciated into itself, so that in the end only one new attribute row can be added.

BTW: the processing of the attributes may hardened against entering identical attribute ids

try:
attr_id = REQUEST['attr_id_%s'%old_id].strip()
except:
if type(REQUEST.get('attr_id_%s'%old_id))==list:
# Error: doubled attribute ids
standard.writeLog(self, "[ZMSMetaobjManager.manage_changeProperties Doubled Attribute IDs]: %s"%(REQUEST.get('old_ids', [])))
message+='IGNORED Doubled ID: attr_id_%s<br/>'%(old_id)
attr_id = REQUEST['attr_id_%s'%old_id][0].strip()
continue
else:
standard.writeLog(self, "[ZMSMetaobjManager.manage_changeProperties Key Error]: attr_id_%s"%(old_id))
message+='IGNORED Key: attr_id_%s<br/>'%(old_id)
continue

Intermediate saving on adding new attributes
to the content model  not necessary anymore
@drfho drfho requested a review from zmsdev July 12, 2023 14:55

try:
attr_id = REQUEST['attr_id_%s'%old_id].strip()
except:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when can this happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attr_id can be not a string but a list if id (unitentionally) occurs 2x by multiple row posting. And strip() does not work on lists, If a list tyoe can be avoided for sure, this exception is not needed, of course.

$(this).attr('name', `attr_${newname}_new${new_row_counter}`);
};
case 'meta_languages':
$(this).attr('name',$(this).attr('name').replace('_0', '_' + (lang_count + new_row_counter)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we need an individual row-counter for each table?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think so, because counter is need for the ex-ante (temporarily) name unification (that is "corrected" by the ZMSMetaobjManager.manage_changeProperties() applying the old_id-mechanism).
BTW: Maybe we can get rid of the counter at all, when generally changing all the new row's form names on-blur according to the input-value of the meta-id field. The current JS code may be considered as too long ;-)

@drfho drfho merged commit 5e57162 into main Jul 14, 2023
13 checks passed
@drfho drfho deleted the fb_adding_multiple_rows branch September 1, 2023 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants