FIX: Remove Deprecated Views
This commit is contained in:
parent
0d62ad73d4
commit
91815c9f00
|
@ -0,0 +1,76 @@
|
|||
import { observes } from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
|
||||
@observes('hideSchema')
|
||||
_onHideSchema() {
|
||||
this.appEvents.trigger('ace:resize');
|
||||
},
|
||||
|
||||
@observes('everEditing')
|
||||
_onInsertEditor() {
|
||||
Ember.run.schedule('afterRender', this, () => this._bindControls());
|
||||
},
|
||||
|
||||
_bindControls() {
|
||||
if (this._state !== "inDOM") {
|
||||
return;
|
||||
}
|
||||
const $editPane = this.$().find('.query-editor');
|
||||
if (!$editPane.length) {
|
||||
return;
|
||||
}
|
||||
const oldGrippie = this.get('grippie');
|
||||
if (oldGrippie) {
|
||||
oldGrippie.off('mousedown mousemove mouseup');
|
||||
$editPane.off('mousemove mouseup');
|
||||
}
|
||||
|
||||
const $grippie = $editPane.find('.grippie');
|
||||
const $targets = $editPane.find('.ace-wrapper,.grippie-target');
|
||||
const $body = $('body');
|
||||
const self = this;
|
||||
|
||||
this.set('grippie', $grippie);
|
||||
|
||||
const mousemove = function(e) {
|
||||
const diff = self.get('startY') - e.screenY;
|
||||
const newHeight = self.get('startSize') - diff;
|
||||
//Em.Logger.debug("new height", newHeight);
|
||||
$targets.height(newHeight);
|
||||
self.appEvents.trigger('ace:resize');
|
||||
};
|
||||
|
||||
let mouseup;
|
||||
mouseup = function(e) {
|
||||
mousemove(e);
|
||||
$body.off('mousemove', mousemove);
|
||||
$body.off('mouseup', mouseup);
|
||||
self.set('startY', null);
|
||||
self.set('startSize', null);
|
||||
};
|
||||
|
||||
$grippie.on('mousedown', function(e) {
|
||||
self.set('startY', e.screenY);
|
||||
self.set('startSize', $targets.height());
|
||||
|
||||
$body.on('mousemove', mousemove);
|
||||
$body.on('mouseup', mouseup);
|
||||
e.preventDefault();
|
||||
});
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this._super();
|
||||
this._bindControls();
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this._super();
|
||||
if (this.get('everEditing')) {
|
||||
this.get('grippie').off('mousedown');
|
||||
this.set('grippie', null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -1,136 +1,139 @@
|
|||
{{#if disallow}}
|
||||
<h2>{{i18n "explorer.admins_only"}}</h2>
|
||||
{{else}}
|
||||
<div class="query-list">
|
||||
{{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"}}
|
||||
</div>
|
||||
{{#explorer-container hideSchema=hideSchema everEditing=everEditing}}
|
||||
|
||||
{{#if showCreate}}
|
||||
<div class="query-create">
|
||||
{{text-field value=newQueryName placeholderKey="explorer.create_placeholder"}}
|
||||
{{d-button action="create" label="explorer.create" icon="plus" class="btn-primary"}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if othersDirty}}
|
||||
<div class="warning">
|
||||
{{fa-icon "warning"}}
|
||||
{{i18n "explorer.others_dirty"}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<hr>
|
||||
|
||||
{{#if selectedItem.fake}}
|
||||
{{i18n "explorer.no_queries"}} <a {{action "showCreate"}}>{{i18n "explorer.no_queries_hook"}}</a>
|
||||
{{#if disallow}}
|
||||
<h2>{{i18n "explorer.admins_only"}}</h2>
|
||||
{{else}}
|
||||
<div class="query-edit {{if editName "editing"}}">
|
||||
{{#if selectedItem}}
|
||||
{{#if editing}}
|
||||
<div class="name">
|
||||
{{text-field value=selectedItem.name}}
|
||||
</div>
|
||||
<div class="desc">
|
||||
{{textarea value=selectedItem.description}}
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="name">
|
||||
<h2>{{selectedItem.name}}</h2>
|
||||
{{d-button action="editName" icon="pencil" class="no-text btn-small"}}
|
||||
</div>
|
||||
<div class="desc">
|
||||
{{selectedItem.description}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{! the SQL editor will show the first time you }}
|
||||
{{#if everEditing}}
|
||||
<div class="query-editor {{if hideSchema "no-schema"}}">
|
||||
<div class="right-panel">
|
||||
<div class="schema grippie-target">
|
||||
{{explorer-schema schema=schema hideSchema=hideSchema}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="editor-panel">
|
||||
{{ace-editor content=selectedItem.sql mode="sql"}}
|
||||
</div>
|
||||
<div class="grippie"></div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="sql">
|
||||
{{hljs-code-view value=selectedItem.sql codeClass="sql"}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
|
||||
|
||||
<div class="clear"></div>
|
||||
<div class="pull-left">
|
||||
{{#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"}}
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
{{#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}}
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
{{/if}}
|
||||
<div class="query-list">
|
||||
{{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"}}
|
||||
</div>
|
||||
|
||||
<form class="query-run" {{action "run" on="submit"}}>
|
||||
{{#if selectedItem.hasParams}}
|
||||
<div class="query-params">
|
||||
{{#each selectedItem.param_info as |pinfo|}}
|
||||
{{param-input params=selectedItem.params info=pinfo}}
|
||||
{{! <div class="param">
|
||||
{{param-field params=selectedItem.params pname=pinfo.identifier type=pinfo.type}
|
||||
<span class="param-name">{{pinfo.identifier}</span>
|
||||
</div> }}
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/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}}
|
||||
<label class="query-plan">{{input type="checkbox" checked=explain name="explain"}} {{i18n "explorer.explain_label"}}</label>
|
||||
</form>
|
||||
|
||||
<hr>
|
||||
{{/if}}
|
||||
{{conditional-loading-spinner condition=loading}}
|
||||
{{#unless selectedItem.fake}}
|
||||
{{#if results}}
|
||||
<div class="query-results">
|
||||
{{#if showResults}}
|
||||
{{query-result query=selectedItem content=results}}
|
||||
{{else}}
|
||||
{{#each results.errors as |err|}}
|
||||
<pre class="query-error"><code>{{~err}}</code></pre>
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{#if showCreate}}
|
||||
<div class="query-create">
|
||||
{{text-field value=newQueryName placeholderKey="explorer.create_placeholder"}}
|
||||
{{d-button action="create" label="explorer.create" icon="plus" class="btn-primary"}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
|
||||
<div class="explorer-pad-bottom"></div>
|
||||
{{#if othersDirty}}
|
||||
<div class="warning">
|
||||
{{fa-icon "warning"}}
|
||||
{{i18n "explorer.others_dirty"}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{/if}}
|
||||
<hr>
|
||||
|
||||
{{#if selectedItem.fake}}
|
||||
{{i18n "explorer.no_queries"}} <a {{action "showCreate"}}>{{i18n "explorer.no_queries_hook"}}</a>
|
||||
{{else}}
|
||||
<div class="query-edit {{if editName "editing"}}">
|
||||
{{#if selectedItem}}
|
||||
{{#if editing}}
|
||||
<div class="name">
|
||||
{{text-field value=selectedItem.name}}
|
||||
</div>
|
||||
<div class="desc">
|
||||
{{textarea value=selectedItem.description}}
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="name">
|
||||
<h2>{{selectedItem.name}}</h2>
|
||||
{{d-button action="editName" icon="pencil" class="no-text btn-small"}}
|
||||
</div>
|
||||
<div class="desc">
|
||||
{{selectedItem.description}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{! the SQL editor will show the first time you }}
|
||||
{{#if everEditing}}
|
||||
<div class="query-editor {{if hideSchema "no-schema"}}">
|
||||
<div class="right-panel">
|
||||
<div class="schema grippie-target">
|
||||
{{explorer-schema schema=schema hideSchema=hideSchema}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="editor-panel">
|
||||
{{ace-editor content=selectedItem.sql mode="sql"}}
|
||||
</div>
|
||||
<div class="grippie"></div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="sql">
|
||||
{{hljs-code-view value=selectedItem.sql codeClass="sql"}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
|
||||
|
||||
<div class="clear"></div>
|
||||
<div class="pull-left">
|
||||
{{#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"}}
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
{{#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}}
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
<form class="query-run" {{action "run" on="submit"}}>
|
||||
{{#if selectedItem.hasParams}}
|
||||
<div class="query-params">
|
||||
{{#each selectedItem.param_info as |pinfo|}}
|
||||
{{param-input params=selectedItem.params info=pinfo}}
|
||||
{{! <div class="param">
|
||||
{{param-field params=selectedItem.params pname=pinfo.identifier type=pinfo.type}
|
||||
<span class="param-name">{{pinfo.identifier}</span>
|
||||
</div> }}
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/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}}
|
||||
<label class="query-plan">{{input type="checkbox" checked=explain name="explain"}} {{i18n "explorer.explain_label"}}</label>
|
||||
</form>
|
||||
|
||||
<hr>
|
||||
{{/if}}
|
||||
{{conditional-loading-spinner condition=loading}}
|
||||
{{#unless selectedItem.fake}}
|
||||
{{#if results}}
|
||||
<div class="query-results">
|
||||
{{#if showResults}}
|
||||
{{query-result query=selectedItem content=results}}
|
||||
{{else}}
|
||||
{{#each results.errors as |err|}}
|
||||
<pre class="query-error"><code>{{~err}}</code></pre>
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
|
||||
<div class="explorer-pad-bottom"></div>
|
||||
|
||||
{{/if}}
|
||||
{{/explorer-container}}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<form {{action "dummy" on="submit"}}>
|
||||
<div class='modal-body'>
|
||||
{{json-file-uploader value=queryFile extension=".dcquery.json"}}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
{{d-button class='btn-primary' action='doImport' type='submit' disabled=notReady icon="plus" label='explorer.import.label'}}
|
||||
</div>
|
||||
</form>
|
||||
{{#d-modal-body title="explorer.import.modal"}}
|
||||
<form {{action "dummy" on="submit"}}>
|
||||
<div class='modal-body'>
|
||||
{{json-file-uploader value=queryFile extension=".dcquery.json"}}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
{{d-button class='btn-primary' action='doImport' type='submit' disabled=notReady icon="plus" label='explorer.import.label'}}
|
||||
</div>
|
||||
</form>
|
||||
{{/d-modal-body}}
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
|
||||
export default Ember.View.extend({
|
||||
|
||||
_onHideSchema: function() {
|
||||
this.appEvents.trigger('ace:resize');
|
||||
}.observes('controller.hideSchema'),
|
||||
|
||||
_onInsertEditor: function() {
|
||||
const self = this;
|
||||
Em.run.schedule('afterRender', this, function() {
|
||||
self.trigger('didInsertEditor');
|
||||
});
|
||||
}.observes('controller.everEditing'),
|
||||
|
||||
_bindGrippie: function() {
|
||||
if (this._state !== "inDOM") {
|
||||
return;
|
||||
}
|
||||
const $editPane = this.$().find('.query-editor');
|
||||
if (!$editPane.length) {
|
||||
return;
|
||||
}
|
||||
const oldGrippie = this.get('grippie');
|
||||
if (oldGrippie) {
|
||||
oldGrippie.off('mousedown mousemove mouseup');
|
||||
$editPane.off('mousemove mouseup');
|
||||
}
|
||||
|
||||
const $grippie = $editPane.find('.grippie');
|
||||
const $targets = $editPane.find('.ace-wrapper,.grippie-target');
|
||||
const $body = $('body');
|
||||
const self = this;
|
||||
|
||||
this.set('grippie', $grippie);
|
||||
|
||||
const mousemove = function(e) {
|
||||
const diff = self.get('startY') - e.screenY;
|
||||
const newHeight = self.get('startSize') - diff;
|
||||
//Em.Logger.debug("new height", newHeight);
|
||||
$targets.height(newHeight);
|
||||
self.appEvents.trigger('ace:resize');
|
||||
};
|
||||
|
||||
let mouseup;
|
||||
mouseup = function(e) {
|
||||
mousemove(e);
|
||||
$body.off('mousemove', mousemove);
|
||||
$body.off('mouseup', mouseup);
|
||||
self.set('startY', null);
|
||||
self.set('startSize', null);
|
||||
};
|
||||
|
||||
$grippie.on('mousedown', function(e) {
|
||||
self.set('startY', e.screenY);
|
||||
self.set('startSize', $targets.height());
|
||||
|
||||
$body.on('mousemove', mousemove);
|
||||
$body.on('mouseup', mouseup);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
}.on('didInsertElement', 'didInsertEditor'),
|
||||
|
||||
_cleanup: function() {
|
||||
if (this.get('controller.everEditing')) {
|
||||
this.get('grippie').off('mousedown');
|
||||
this.set('grippie', null);
|
||||
}
|
||||
}.on('willDestroyElement')
|
||||
});
|
|
@ -1,6 +0,0 @@
|
|||
import ModalBodyView from "discourse/views/modal-body";
|
||||
|
||||
export default ModalBodyView.extend({
|
||||
templateName: 'modal/import-query',
|
||||
title: I18n.t('explorer.import.modal')
|
||||
});
|
Loading…
Reference in New Issue