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({
selectedItem: null,
dirty: false,
loading: false,
markDirty: function() {
this.set('dirty', true);
}.observes('selectedItem.name', 'selectedItem.description', 'selectedItem.sql'),
actions: {
selectItem(item) {
this.set('selectedItem', item);
this.setProperties({
selectedItem: item,
editName: false
});
this.set('dirty', false);
},
dummy() {},
create() {
const self = this;
this.set('loading', true);
var newQuery = this.store.createRecord('query', {name: this.get('newQueryName')});
newQuery.save().then(function(result) {
self.pushObject(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');
},
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() {
if (this.get('dirty')) {
self.set('results', {errors: [I18n.t('errors.explorer.dirty')]});
return;
}
const self = this;
this.set('loading', true);
Discourse.ajax("/admin/plugins/explorer/query/" + this.get('selectedItem.id') + "/run", {

View File

@ -1,21 +1,23 @@
{{#if model}}
{{#if selectedItem}}
<div class="name">
{{#if editName}}
{{text-field value=model.name}}
{{text-field value=selectedItem.name}}
{{else}}
<h2>{{model.name}}</h2>
<h2>{{selectedItem.name}}</h2>
{{d-button action="editName" icon="pencil" class="no-text"}}
{{/if}}
</div>
<div class="desc">
{{#if editName}}
{{textarea value=model.description}}
{{#if controller.editName}}
{{textarea value=selectedItem.description}}
{{else}}
{{model.description}}
{{selectedItem.description}}
{{/if}}
</div>
<div class="sql">
{{textarea value=model.sql}}
{{textarea value=selectedItem.sql}}
</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}}

View File

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

View File

@ -20,6 +20,7 @@ en:
errors:
explorer:
no_semicolons: "Remove the semicolons from the query."
dirty: "You must save the query before running."
explorer:
title: "Data Explorer"
create: "Create New"
@ -28,4 +29,5 @@ en:
label: "Import"
modal: "Import A Query"
export: "Export"
save: "Save Changes"
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: "一个标签允许的最大字符数"