FIX: Remove Deprecated Views

This commit is contained in:
Robin Ward 2016-12-01 13:54:21 -05:00
parent 0d62ad73d4
commit 91815c9f00
5 changed files with 217 additions and 212 deletions

View File

@ -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);
}
}
});

View File

@ -1,3 +1,5 @@
{{#explorer-container hideSchema=hideSchema everEditing=everEditing}}
{{#if disallow}} {{#if disallow}}
<h2>{{i18n "explorer.admins_only"}}</h2> <h2>{{i18n "explorer.admins_only"}}</h2>
{{else}} {{else}}
@ -134,3 +136,4 @@
<div class="explorer-pad-bottom"></div> <div class="explorer-pad-bottom"></div>
{{/if}} {{/if}}
{{/explorer-container}}

View File

@ -1,3 +1,4 @@
{{#d-modal-body title="explorer.import.modal"}}
<form {{action "dummy" on="submit"}}> <form {{action "dummy" on="submit"}}>
<div class='modal-body'> <div class='modal-body'>
{{json-file-uploader value=queryFile extension=".dcquery.json"}} {{json-file-uploader value=queryFile extension=".dcquery.json"}}
@ -6,3 +7,4 @@
{{d-button class='btn-primary' action='doImport' type='submit' disabled=notReady icon="plus" label='explorer.import.label'}} {{d-button class='btn-primary' action='doImport' type='submit' disabled=notReady icon="plus" label='explorer.import.label'}}
</div> </div>
</form> </form>
{{/d-modal-body}}

View File

@ -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')
});

View File

@ -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')
});