FEATURE: Add hide button (toggleable) for all queries (frontend only)

* Switches between hide/unhide on click
* Works almost like the delete button, but toggles between the query's
hidden attribute instead
* So far this is only a frontend feature, the backend implementation
still needs work
This commit is contained in:
Ricky Chon 2020-07-14 11:24:24 -04:00
parent 0c1a9aa4bc
commit a8771d2ad5
3 changed files with 36 additions and 3 deletions

View File

@ -236,6 +236,32 @@ export default Ember.Controller.extend({
}); });
}, },
hide() {
const query = this.selectedItem;
this.setProperties({ loading: true, showResults: false });
query.set("isNew", true);
this.store
.destroyRecord("query", query)
.then(() => query.set("hidden", true))
.catch(popupAjaxError)
.finally(() => {
query.set("isNew", false);
this.set("loading", false);
});
},
unhide() {
const query = this.selectedItem;
this.setProperties({ loading: true, showResults: true });
query
.save()
.then(() => query.set("hidden", false))
.catch(popupAjaxError)
.finally(() => this.set("loading", false));
},
run() { run() {
if (this.get("selectedItem.dirty")) { if (this.get("selectedItem.dirty")) {
return; return;

View File

@ -118,9 +118,14 @@
{{#if everEditing}} {{#if everEditing}}
{{d-button action=(action "discard") icon="undo" label="explorer.undo" disabled=saveDisabled}} {{d-button action=(action "discard") icon="undo" label="explorer.undo" disabled=saveDisabled}}
{{/if}} {{/if}}
{{#unless editDisabled}} {{#if selectedItem.hidden}}
{{d-button action=(action "destroy") class="btn-danger" icon="trash-alt" label="explorer.delete"}} {{d-button action=(action "unhide") icon="undo" label="explorer.unhide"}}
{{/unless}} {{else}}
{{d-button action=(action "hide") icon="far-eye-slash" label="explorer.hide"}}
{{#unless editDisabled}}
{{d-button action=(action "destroy") class="btn-danger" icon="trash-alt" label="explorer.delete"}}
{{/unless}}
{{/if}}
{{/if}} {{/if}}
</div> </div>
<div class="clear"></div> <div class="clear"></div>

View File

@ -49,6 +49,8 @@ en:
edit: "Edit" edit: "Edit"
delete: "Delete" delete: "Delete"
recover: "Undelete Query" recover: "Undelete Query"
hide: "Hide"
unhide: "Unhide Query"
download_json: "JSON" download_json: "JSON"
download_csv: "CSV" download_csv: "CSV"
others_dirty: "A query has unsaved changes that will be lost if you navigate away." others_dirty: "A query has unsaved changes that will be lost if you navigate away."