Skip to content

Commit

Permalink
Prettier on JS only.
Browse files Browse the repository at this point in the history
  • Loading branch information
ermbutler committed Aug 17, 2023
1 parent c98b819 commit 640ba2b
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 106 deletions.
2 changes: 1 addition & 1 deletion ui/src/js/components/inputs/email-list-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class EmailListInput extends TatorElement {
}

clear() {
if(this._input && this._input.setValue) this._input.setValue("");
if (this._input && this._input.setValue) this._input.setValue("");
this._pills.innerHTML = "";
}
}
Expand Down
3 changes: 1 addition & 2 deletions ui/src/js/organization-settings/affiliation-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,14 @@ export class AffiliationEdit extends OrgTypeFormTemplate {
}

this._permissionSelect._select.required = this._data?.id === "New";

if (this._data?.id === "New" || !this._data) {
this._permissionSelect.setValue("Member");
this._permissionSelect.default = "Member";
} else {
this._permissionSelect.setValue(this._data.permission);
this._permissionSelect.default = this._data.permission;
}

}

_getFormData() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class AffiliationMembershipDialog extends ModalDialog {

showHiddenNewFields() {
const versionChosen = this._versions.getValue();

if (
versionChosen === "__add_custom_version_name" ||
versionChosen === "__add_user_first_last"
Expand Down Expand Up @@ -160,15 +160,13 @@ export class AffiliationMembershipDialog extends ModalDialog {
skipList = store
.getState()
.Membership.usernameProjectIdMap.get(this._username);

}


const projectChoices = await getCompiledList({
type: "Project",
skip: Array.from(skipList),
});

if (projectChoices.length === 1) {
this._messageList.innerHTML = `
<li>${
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class OrgTypeAffiliateContainer extends OrgTypeFormContainer {
this._form.data = data;

// Setup object info
const userName = data?.username ? data.username : ""
const userName = data?.username ? data.username : "";
this.objectName = userName;
this.updateAffiliateSidebar(userName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class OrgTypeFormContainer extends TatorElement {
let objectName = "";

// Setup object info
this.objectName = data?.name ? data.name : "";;
this.objectName = data?.name ? data.name : "";
}

/**
Expand Down Expand Up @@ -220,11 +220,8 @@ export class OrgTypeFormContainer extends TatorElement {
this._form.data = data;
return;
}

}



/* Clear container in any other case */
// ie. NEW form (data is null), or no data from store
this.resetToNew();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class OrgTypeFormTemplate extends TatorElement {
const info = {
type: this.typeName,
id: this.typeId,
data: formData
data: formData,
};

if (this.typeId == "New" && isArray) {
Expand Down Expand Up @@ -188,25 +188,30 @@ export class OrgTypeFormTemplate extends TatorElement {

if (sCount > 0 && eCount === 0) {
return this.modal._success(
`Successfully added ${sCount} ${this.typeName}${sCount == 1 ? "" : "s"
}.`
`Successfully added ${sCount} ${this.typeName}${
sCount == 1 ? "" : "s"
}.`
);
} else if (sCount > 0 && eCount > 0) {
return this.modal._complete(
`Successfully added ${sCount} ${this.typeName
}s.<br/><br/>Error adding ${eCount} ${this.typeName}${eCount == 1 ? "" : "s"
}.<br/><br/>Error message${eCount == 1 ? "" : "s"
`Successfully added ${sCount} ${
this.typeName
}s.<br/><br/>Error adding ${eCount} ${this.typeName}${
eCount == 1 ? "" : "s"
}.<br/><br/>Error message${
eCount == 1 ? "" : "s"
}:<br/><br/>${errors}`
);
} else {
return this.modal._error(
`Error adding ${eCount} ${this.typeName}${eCount == 1 ? "" : "s"
}.<br/><br/>Error message${eCount == 1 ? "" : "s"
`Error adding ${eCount} ${this.typeName}${
eCount == 1 ? "" : "s"
}.<br/><br/>Error message${
eCount == 1 ? "" : "s"
}:<br/><br/>${errors}`
);
}
}

}

// Use the most recently set data to update the values of form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ export class OrgTypeInvitationContainer extends OrgTypeFormContainer {

this.objectName = data && data.email ? data.email : "";
const status = this._form?._data?.status ? this._form._data.status : null;
this._setupButtonsInvite(status);


this._setupButtonsInvite(status);
}

async _resetInvitation() {
Expand All @@ -88,7 +86,6 @@ export class OrgTypeInvitationContainer extends OrgTypeFormContainer {
async _setupButtonsInvite(status) {
const showReset = ["Expired", "Pending"];
const showCustomButton = showReset.includes(status) || status == "Accepted";


if (showCustomButton) {
if (showReset.includes(status)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class ProjectMembershipSidebar extends TatorElement {
.currentUser.membershipsByProject.has(projectId)
? true
: false;

await store.getState().initType("Affiliation");
if (!hasControl) {
this._addNew.classList.add("hidden");
Expand Down
3 changes: 1 addition & 2 deletions ui/src/js/organization-settings/invitation-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ export class InvitationEdit extends OrgTypeFormTemplate {
this._permissionSelect.default = this._data.permission;
} else {
this._permissionSelect.setValue("Member");
this._permissionSelect.default = "Member";

this._permissionSelect.default = "Member";
}
this._permissionSelect.permission = "Can Edit";

Expand Down
2 changes: 1 addition & 1 deletion ui/src/js/organization-settings/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ const store = create(

if (responseInfo?.data?.id) {
const newID = responseInfo?.data?.id ? responseInfo.data.id : "New";
window.location = `${window.location.origin}${window.location.pathname}#${type}-${newID}`;
window.location = `${window.location.origin}${window.location.pathname}#${type}-${newID}`;
}

set({ status: { ...get().status, name: "idle", msg: "" } });
Expand Down
147 changes: 76 additions & 71 deletions ui/src/js/project-settings/components/type-form-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class TypeFormTemplate extends TatorElement {
const info = {
type: this.typeName,
id: this.typeId,
data: formData
data: formData,
};

console.log("Form data", formData);
Expand Down Expand Up @@ -187,99 +187,104 @@ export class TypeFormTemplate extends TatorElement {

if (sCount > 0 && eCount === 0) {
return this.modal._success(
`Successfully added ${sCount} ${this.typeName}${sCount == 1 ? "" : "s"
}.`
`Successfully added ${sCount} ${this.typeName}${
sCount == 1 ? "" : "s"
}.`
);
} else if (sCount > 0 && eCount > 0) {
return this.modal._complete(
`Successfully added ${sCount} ${this.typeName
}s.<br/><br/>Error adding ${eCount} ${this.typeName}${eCount == 1 ? "" : "s"
}.<br/><br/>Error message${eCount == 1 ? "" : "s"
`Successfully added ${sCount} ${
this.typeName
}s.<br/><br/>Error adding ${eCount} ${this.typeName}${
eCount == 1 ? "" : "s"
}.<br/><br/>Error message${
eCount == 1 ? "" : "s"
}:<br/><br/>${errors}`
);
} else {
return this.modal._error(
`Error adding ${eCount} ${this.typeName}${eCount == 1 ? "" : "s"
}.<br/><br/>Error message${eCount == 1 ? "" : "s"
`Error adding ${eCount} ${this.typeName}${
eCount == 1 ? "" : "s"
}.<br/><br/>Error message${
eCount == 1 ? "" : "s"
}:<br/><br/>${errors}`
);
}
}
}
// Use the most recently set data to update the values of form
_resetForm(evt) {
evt.preventDefault();
this.data = null;
}
// Use the most recently set data to update the values of form
_resetForm(evt) {
evt.preventDefault();
this.data = null;
}

async _deleteType() {
const button = document.createElement("button");
button.setAttribute("class", "btn btn-clear f1 text-semibold btn-red");
const button = document.createElement("button");
button.setAttribute("class", "btn btn-clear f1 text-semibold btn-red");

let confirmText = document.createTextNode("Confirm");
button.appendChild(confirmText);
let confirmText = document.createTextNode("Confirm");
button.appendChild(confirmText);

button.addEventListener("click", this.asyncDelete.bind(this));
await this.setUpWarningDeleteMsg();
button.addEventListener("click", this.asyncDelete.bind(this));
await this.setUpWarningDeleteMsg();

this.modal._confirm({
titleText: `Delete Confirmation`,
mainText: this._warningDeleteMessage,
buttonSave: button,
});
}

this.modal._confirm({
titleText: `Delete Confirmation`,
mainText: this._warningDeleteMessage,
buttonSave: button,
});
}

async asyncDelete() {
this.modal._modalCloseAndClear();
try {
const respData = await store
.getState()
.removeType({ type: this.typeName, id: this._data.id });
this.handleResponse(respData);

if (this.typeName == "Project") {
setTimeout(function () {
window.location.href = "/projects/";
}, 3000);
} else {
window.location.replace(
`${window.location.origin}${window.location.pathname}#${this.typeName}-New`
);
}
} catch (err) {
this.modal._error(err);
this.modal._modalCloseAndClear();
try {
const respData = await store
.getState()
.removeType({ type: this.typeName, id: this._data.id });
this.handleResponse(respData);

if (this.typeName == "Project") {
setTimeout(function () {
window.location.href = "/projects/";
}, 3000);
} else {
window.location.replace(
`${window.location.origin}${window.location.pathname}#${this.typeName}-New`
);
}
} catch (err) {
this.modal._error(err);
}
}

_getEmptyData() {
this.typeId = "New";
this.objectName = "";
return {
id: `New`,
name: "+ Add New",
project: this.projectId,
description: "",
visible: false,
grouping_default: false,
default_volume: 0,
media: [],
dtype: "",
color_map: null,
interpolation: "none",
association: "Media",
line_width: 2,
delete_child_localizations: false,
cluster: null,
manifest: null,
files_per_job: null,
parameters: [],
categories: "",
form: "empty",
};
}
_getEmptyData() {
this.typeId = "New";
this.objectName = "";
return {
id: `New`,
name: "+ Add New",
project: this.projectId,
description: "",
visible: false,
grouping_default: false,
default_volume: 0,
media: [],
dtype: "",
color_map: null,
interpolation: "none",
association: "Media",
line_width: 2,
delete_child_localizations: false,
cluster: null,
manifest: null,
files_per_job: null,
parameters: [],
categories: "",
form: "empty",
};
}
}

if(!customElements.get("type-form-template")) {
if (!customElements.get("type-form-template")) {
customElements.define("type-form-template", TypeFormTemplate);
}
Loading

0 comments on commit 640ba2b

Please sign in to comment.