Tuesday morning, 9 AM

This commit is contained in:
Kane York 2015-06-30 09:07:33 -07:00
parent a12c906c9a
commit 95a50e1116
10 changed files with 60 additions and 104 deletions

View File

@ -3,21 +3,34 @@ import Query from 'discourse/plugins/discourse-data-explorer/discourse/models/qu
export default Ember.ArrayController.extend({ export default Ember.ArrayController.extend({
selectedItem: null, selectedItem: null,
dirty: false,
loading: false,
markDirty: function() {
this.set('dirty', true);
}.observes('selectedItem.name', 'selectedItem.description', 'selectedItem.sql'),
actions: { actions: {
selectItem(item) { selectItem(item) {
this.set('selectedItem', item); this.setProperties({
selectedItem: item,
editName: false
});
this.set('dirty', false);
}, },
dummy() {}, dummy() {},
create() { create() {
const self = this; const self = this;
this.set('loading', true);
var newQuery = this.store.createRecord('query', {name: this.get('newQueryName')}); var newQuery = this.store.createRecord('query', {name: this.get('newQueryName')});
newQuery.save().then(function(result) { newQuery.save().then(function(result) {
self.pushObject(result.target); self.pushObject(result.target);
self.set('selectedItem', result.target); self.set('selectedItem', result.target);
debugger; self.set('dirty', false);
}).finally(function() {
self.set('loading', false);
}); });
}, },
@ -25,7 +38,38 @@ export default Ember.ArrayController.extend({
showModal('import-query'); showModal('import-query');
}, },
editName() {
this.setProperties({
editName: true,
dirty: true
});
},
save() {
const self = this;
this.set('loading', true);
this.get('selectedItem').save().then(function(result) {
debugger;
}).finally(function() {
self.set('loading', false);
});
},
discard() {
const self = this;
this.set('loading', true);
this.store.find('query', this.selectedItem.id).then(function(result) {
self.set('selectedItem', result);
}).finally(function() {
self.set('loading', false);
});
},
run() { run() {
if (this.get('dirty')) {
self.set('results', {errors: [I18n.t('errors.explorer.dirty')]});
return;
}
const self = this; const self = this;
this.set('loading', true); this.set('loading', true);
Discourse.ajax("/admin/plugins/explorer/query/" + this.get('selectedItem.id') + "/run", { Discourse.ajax("/admin/plugins/explorer/query/" + this.get('selectedItem.id') + "/run", {

View File

@ -1,21 +1,23 @@
{{#if model}} {{#if selectedItem}}
<div class="name"> <div class="name">
{{#if editName}} {{#if editName}}
{{text-field value=model.name}} {{text-field value=selectedItem.name}}
{{else}} {{else}}
<h2>{{model.name}}</h2> <h2>{{selectedItem.name}}</h2>
{{d-button action="editName" icon="pencil" class="no-text"}} {{d-button action="editName" icon="pencil" class="no-text"}}
{{/if}} {{/if}}
</div> </div>
<div class="desc"> <div class="desc">
{{#if editName}} {{#if controller.editName}}
{{textarea value=model.description}} {{textarea value=selectedItem.description}}
{{else}} {{else}}
{{model.description}} {{selectedItem.description}}
{{/if}} {{/if}}
</div> </div>
<div class="sql"> <div class="sql">
{{textarea value=model.sql}} {{textarea value=selectedItem.sql}}
</div> </div>
{{d-button action="run" label="explorer.run"}} {{d-button action="save" label="explorer.save" disabled=saveDisabled}}
{{d-button action="discard" class="no-text danger" icon="trash" disabled=saveDisabled}}
{{d-button action="run" label="explorer.run" disabled=runDisabled}}
{{/if}} {{/if}}

View File

@ -22,9 +22,10 @@
</div> </div>
<hr> <hr>
<div class="query-edit"> <div class="query-edit">
{{render "admin/plugins-explorer-show" selectedItem}} {{partial "admin/plugins-explorer-show" model=selectedItem}}
</div> </div>
<hr> <hr>
{{conditional-loading-spinner condition=loading}}
<div class="query-results"> <div class="query-results">
{{results}} {{results}}
</div> </div>

View File

@ -20,6 +20,7 @@ en:
errors: errors:
explorer: explorer:
no_semicolons: "Remove the semicolons from the query." no_semicolons: "Remove the semicolons from the query."
dirty: "You must save the query before running."
explorer: explorer:
title: "Data Explorer" title: "Data Explorer"
create: "Create New" create: "Create New"
@ -28,4 +29,5 @@ en:
label: "Import" label: "Import"
modal: "Import A Query" modal: "Import A Query"
export: "Export" export: "Export"
save: "Save Changes"
run: "Run Query" run: "Run Query"

View File

@ -1,25 +0,0 @@
# encoding: utf-8
# This file contains content for the client portion of Discourse, sent out
# to the Javascript app.
#
# To work with us on translations, see:
# https://www.transifex.com/projects/p/discourse-org/
#
# This is a "source" file, which is used by Transifex to get translations for other languages.
# After this file is changed, it needs to be pushed by a maintainer to Transifex:
#
# tx push -s
#
# Read more here: https://meta.discourse.org/t/contribute-a-translation-to-discourse/14882
#
# To validate this YAML file after you change it, please paste it into
# http://yamllint.com/
pl_PL:
js:
tagging:
all_tags: "Wszystkie tagi"
changed: "zmienione tagi:"
tags: "Tagi"
choose_for_topic: "wybierz opcjonalne tagi dla tego tematu"
topics_tagged: "Tematy otagowane jako <span class='discourse-tag'>{{tag}}</span>"

View File

@ -1,24 +0,0 @@
# encoding: utf-8
# This file contains content for the client portion of Discourse, sent out
# to the Javascript app.
#
# To work with us on translations, see:
# https://www.transifex.com/projects/p/discourse-org/
#
# This is a "source" file, which is used by Transifex to get translations for other languages.
# After this file is changed, it needs to be pushed by a maintainer to Transifex:
#
# tx push -s
#
# Read more here: https://meta.discourse.org/t/contribute-a-translation-to-discourse/14882
#
# To validate this YAML file after you change it, please paste it into
# http://yamllint.com/
ru:
js:
tagging:
all_tags: "Все теги"
tags: "Теги"
choose_for_topic: "выберите теги для темы"
topics_tagged: "Темы с тегом <span class='discourse-tag'>{{tag}}</span>"

View File

@ -1,25 +0,0 @@
# encoding: utf-8
# This file contains content for the client portion of Discourse, sent out
# to the Javascript app.
#
# To work with us on translations, see:
# https://www.transifex.com/projects/p/discourse-org/
#
# This is a "source" file, which is used by Transifex to get translations for other languages.
# After this file is changed, it needs to be pushed by a maintainer to Transifex:
#
# tx push -s
#
# Read more here: https://meta.discourse.org/t/contribute-a-translation-to-discourse/14882
#
# To validate this YAML file after you change it, please paste it into
# http://yamllint.com/
zh_CN:
js:
tagging:
all_tags: "全部标签"
changed: "标签更改:"
tags: "标签"
choose_for_topic: "选择主题的标签"
topics_tagged: "主题标签: <span class='discourse-tag'>{{tag}}</span>"

View File

@ -1,9 +0,0 @@
pl_PL:
site_settings:
tagging_enabled: "Pozwolić użytkownikom na tagowanie tematów?"
min_trust_to_create_tag: "Minimalny poziom zaufania dla tworzenia nowych tagów."
max_tags_per_topic: "Maksymalna ilość tagów przypisanych do tematu."
max_tag_length: "Maksymalna ilość znaków per tag."
rss_by_tag: "Tematy otagowane jako %{tag}"
rss_description:
tag: "Otagowane tematy"

View File

@ -1,4 +0,0 @@
ru:
site_settings:
min_trust_to_create_tag: "Минимальный уровень доверия для создания тегов."
max_tags_per_topic: "Максимальное количество тегов для темы."

View File

@ -1,6 +0,0 @@
zh_CN:
site_settings:
tagging_enabled: "允许用户为主题设置标签?"
min_trust_to_create_tag: "允许创建标签的最小信任等级"
max_tags_per_topic: "一个主题最多允许被创建多少个标签"
max_tag_length: "一个标签允许的最大字符数"