change to only add if editing existing container, add initial logic for adding
This commit is contained in:
parent
d43be8cfbe
commit
f2b42626fb
2 changed files with 15 additions and 2 deletions
|
@ -1054,6 +1054,11 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
|
|||
this._submitForm();
|
||||
});
|
||||
|
||||
// Add new site to current container
|
||||
const siteLink = document.querySelector("#edit-container-site-link");
|
||||
Logic.addEnterHandler(siteLink, () => {
|
||||
this._addSite();
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
@ -1078,6 +1083,12 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
|
|||
}
|
||||
},
|
||||
|
||||
async _addSite() {
|
||||
const formValues = new FormData(this._editForm);
|
||||
console.log(formValues.get("container-id"));
|
||||
console.log(formValues.get("site-name"));
|
||||
},
|
||||
|
||||
showAssignedContainers(assignments) {
|
||||
const assignmentPanel = document.getElementById("edit-sites-assigned");
|
||||
const assignmentKeys = Object.keys(assignments);
|
||||
|
@ -1161,6 +1172,8 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
|
|||
const assignments = await Logic.getAssignmentObjectByContainer(userContextId);
|
||||
this.showAssignedContainers(assignments);
|
||||
document.querySelector("#edit-container-panel .panel-footer").hidden = !!userContextId;
|
||||
// Only show ability to add site if it's an existing container
|
||||
document.querySelector("#edit-container-panel-add-site").hidden = !userContextId;
|
||||
|
||||
document.querySelector("#edit-container-panel-name-input").value = identity.name || "";
|
||||
document.querySelector("#edit-container-panel-usercontext-input").value = userContextId || NEW_CONTAINER_ID;
|
||||
|
|
|
@ -204,8 +204,8 @@
|
|||
<fieldset id="edit-container-panel-choose-icon" class="radio-choice">
|
||||
<legend>Choose an icon</legend>
|
||||
</fieldset>
|
||||
<fieldset id="edit-container-panel-add-site">
|
||||
<legend>Add site</legend>
|
||||
<fieldset id="edit-container-panel-add-site" hidden>
|
||||
<legend>Assign site</legend>
|
||||
<input type="text" name="site-name" id="edit-container-panel-site-input"/>
|
||||
<a class="button secondary" id="edit-container-site-link">Add</a>
|
||||
</fieldset>
|
||||
|
|
Loading…
Add table
Reference in a new issue