Skip to content

Commit

Permalink
wait for async content before creating dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
le-jeu committed Jul 18, 2021
1 parent 383ea18 commit 4f63194
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/code/dialogs/linkListDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const LinkListDialog = OperationChecklistDialog.extend({
return fields.slice(0, 2).concat(linkFields, fields.slice(3));
},

_displayDialog: function () {
_displayDialog: async function () {
const operation = getSelectedOperation();
loadFaked(operation);
const links = operation.getLinkListFromPortal(this.options.portal);
Expand All @@ -61,6 +61,8 @@ const LinkListDialog = OperationChecklistDialog.extend({
this.closeDialog();
};

await this.sortable.done;

this.createDialog({
title: wX("LINKS2", {
portalName: PortalUI.displayName(this.options.portal),
Expand Down
18 changes: 9 additions & 9 deletions src/code/dialogs/manageTeamDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const ManageTeamDialog = WDialog.extend({
window.map.off("wasabee:logout", this.closeDialog, this);
},

_setupTable: function () {
_setupTable: async function () {
const table = new Sortable();
table.fields = [
{
Expand Down Expand Up @@ -128,8 +128,7 @@ const ManageTeamDialog = WDialog.extend({
];
table.sortBy = 0;

// async populate
this._refreshTeam(table);
await this._refreshTeam(table);

return table;
},
Expand All @@ -147,19 +146,20 @@ const ManageTeamDialog = WDialog.extend({
}
},

update: function () {
const container = this._dialogContent(); // build the UI
update: async function () {
const container = await this._dialogContent(); // build the UI
// this is the correct way to change out a dialog's contents, audit the entire codebase making this change
this.setContent(container);
this.setTitle(wX("MANAGE_TEAM", { teamName: this.options.team.Name }));
},

_dialogContent: function () {
_dialogContent: async function () {
const container = L.DomUtil.create("div", "container");
const list = L.DomUtil.create("div", "list", container);

const table = this._setupTable();
const table = await this._setupTable();
list.appendChild(table.table);
await table.done;

const addlabel = L.DomUtil.create("label", null, container);
addlabel.textContent = wX("ADD_AGENT");
Expand Down Expand Up @@ -305,8 +305,8 @@ const ManageTeamDialog = WDialog.extend({
return container;
},

_displayDialog: function () {
const container = this._dialogContent();
_displayDialog: async function () {
const container = await this._dialogContent();
const buttons = {};
buttons[wX("CLOSE")] = () => {
this.closeDialog();
Expand Down
4 changes: 3 additions & 1 deletion src/code/dialogs/markerList.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const MarkerList = OperationChecklistDialog.extend({
TYPE: "markerList",
},

_displayDialog: function () {
_displayDialog: async function () {
const operation = getSelectedOperation();
loadFaked(operation);
this.sortable = this.getListDialogContent(
Expand All @@ -27,6 +27,8 @@ const MarkerList = OperationChecklistDialog.extend({
this.closeDialog();
};

await this.sortable.done;

this.createDialog({
title: wX("MARKER_LIST", { opName: operation.name }),
html: this.sortable.table,
Expand Down

0 comments on commit 4f63194

Please sign in to comment.