{{#if disallow}}

{{i18n "explorer.admins_only"}}

{{else}}
{{combo-box valueAttribute="id" value=selectedQueryId nameProperty="listName" content=content castInteger="true" nameChanges="true"}} {{d-button action="showCreate" icon="plus" class="no-text"}} {{d-button action="importQuery" label="explorer.import.label" icon="upload"}}
{{#if showCreate}}
{{text-field value=newQueryName placeholderKey="explorer.create_placeholder"}} {{d-button action="create" label="explorer.create" icon="plus" class="btn-primary"}}
{{/if}} {{#if othersDirty}}
{{fa-icon "warning"}} {{i18n "explorer.others_dirty"}}
{{/if}}
{{#if selectedItem.fake}} {{i18n "explorer.no_queries"}} {{i18n "explorer.no_queries_hook"}} {{else}}
{{#if selectedItem}} {{#if editing}}
{{text-field value=selectedItem.name}}
{{textarea value=selectedItem.description}}
{{else}}

{{selectedItem.name}}

{{d-button action="editName" icon="pencil" class="no-text btn-small"}}
{{selectedItem.description}}
{{/if}} {{! the SQL editor will show the first time you }} {{#if everEditing}}
{{explorer-schema schema=schema hideSchema=hideSchema}}
{{ace-editor content=selectedItem.sql mode="sql"}}
{{else}}
{{hljs-code-view value=selectedItem.sql codeClass="sql"}}
{{/if}}
{{#if everEditing}} {{d-button action="save" label="explorer.save" disabled=saveDisabled class="btn-primary"}} {{else}} {{d-button action="editName" label="explorer.edit" icon="pencil" class="btn-primary"}} {{/if}} {{d-button action="download" label="explorer.export" disabled=runDisabled icon="download"}}
{{#if selectedItem.destroyed}} {{d-button action="recover" class="" icon="undo" label="explorer.recover"}} {{else}} {{#if everEditing}} {{d-button action="discard" class="btn-danger" icon="undo" label="explorer.undo" disabled=saveDisabled}} {{/if}} {{d-button action="destroy" class="btn-danger" icon="trash" label="explorer.delete"}} {{/if}}
{{/if}}
{{#if selectedItem.hasParams}}
{{#each selectedItem.param_info as |pinfo|}} {{param-input params=selectedItem.params info=pinfo}} {{!
{{param-field params=selectedItem.params pname=pinfo.identifier type=pinfo.type} {{pinfo.identifier}
}} {{/each}}
{{/if}} {{#if runDisabled}} {{#if saveDisabled}} {{d-button label="explorer.run" disabled="true" class="btn-primary"}} {{else}} {{d-button action="saverun" label="explorer.saverun"}} {{/if}} {{else}} {{d-button action="run" label="explorer.run" disabled=runDisabled class="btn-primary" type="submit"}} {{/if}}

{{/if}} {{conditional-loading-spinner condition=loading}} {{#unless selectedItem.fake}} {{#if results}}
{{#if showResults}} {{query-result query=selectedItem content=results}} {{else}} {{#each results.errors as |err|}}
{{~err}}
{{/each}} {{/if}}
{{/if}} {{/unless}}
{{/if}}