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

Cleaned up the showEditDialog Function #1331

Closed
wants to merge 3 commits into from
Closed

Conversation

AshotN
Copy link
Member

@AshotN AshotN commented Jul 13, 2016

This function had some odd code in it, using recursion to fetch data. So I updated it, should fix the problem where you had to click twice on the edit cog for an edit dialog to display.

This function had some odd code in it, using recursion to fetch data. So I updated it, should fix the problem where you had to click twice on the edit cog for an edit dialog to display.
@AshotN
Copy link
Member Author

AshotN commented Jul 13, 2016

Should fix #1286 and maybe #1236?

data: $(parent.editFormId).serializeArray(),
success: function (resp) {
$('#editdialog').dialog('close');
$.when($.ajax(jsAjaxServer + '/ajax.server.php?page=tag&action=get_tag_map'), $.ajax(jsAjaxServer + '/ajax.server.php?page=tag&action=get_labels')).then(function( a1, a2 ) {
Copy link
Member

Choose a reason for hiding this comment

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

Should be splitted across multiples lines.

Also, a1 and a2 are not really clear names. Why not xhr1 and xhr2 or response1 and response2?

Copy link
Member

Choose a reason for hiding this comment

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

Also, this means we are doing the two requests every time we open the dialog box, isn't it?

I mean the

if (tag_choices == undefined && tag_choices != '')

and

if (label_choices == undefined && label_choices != '')

have disappeared.

Cannot we replace $.ajax with our own Promise doing an ajax call if necessary and returning directly otherwise?

Copy link
Member Author

Choose a reason for hiding this comment

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

The ifs were useless

And I'm unsure about that Promise part, care to show me an example.

Copy link
Member

Choose a reason for hiding this comment

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

As far as I understand, tag_choices is empty at the first run, then, the if ensures that we load them from the AJAX call. On the subsequent runs, tag_choices is no longer empty and the AJAX call is not done anymore.

I have the impression that we are making an AJAX call systematically with the refactor, whereas we were saving one call with the already existing version. Isn't it?

@Phyks
Copy link
Member

Phyks commented Jul 15, 2016

Did a quick review. Noticed issues are mostly details. I tested it on my instance and it works great!

@AshotN
Copy link
Member Author

AshotN commented Jul 17, 2016

When I get a second I'll fix the small problems. Can you show me how error handing should be done though

@Phyks
Copy link
Member

Phyks commented Jul 18, 2016

Typically

sseSource.onerror = function() {

Thanks

@Afterster
Copy link
Member

Thanks @AshotN and thanks for the review @Phyks. I agree with your comments, specifically the one about error handling and the way to preserve the ajax call to retrieve tag map. Do you think you can handle it @AshotN ?

@AshotN
Copy link
Member Author

AshotN commented Nov 12, 2016

I haven't been very active in Github of lates. What was needed in this request to be complete?

@Afterster
Copy link
Member

Me neither @AshotN 😄. Phyks explained the changes to be done on July 15. You should display "other commented on an outdated diff" by clicking on such links.

@AshotN
Copy link
Member Author

AshotN commented Jan 31, 2017

How's that looking @Afterster and @Phyks?

@Afterster
Copy link
Member

Unfortunately @Phyks comments are still valid, specifically about saving Ajax calls (tag_choices and label_choices checks).

@AshotN
Copy link
Member Author

AshotN commented Aug 19, 2017

I'm not sure I'm understanding where we are making excessive Ajax calls.

@lachlan-00 lachlan-00 self-assigned this May 21, 2019
@lachlan-00
Copy link
Member

closing as this was added previously so there's no reason to keep it open.

@lachlan-00 lachlan-00 closed this Aug 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants