diff --git a/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 b/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6
index 65c4833..8a43665 100644
--- a/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6
+++ b/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6
@@ -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", {
diff --git a/assets/javascripts/discourse/templates/admin/plugins-explorer-show.hbs b/assets/javascripts/discourse/templates/admin/plugins-explorer-show.hbs
index 6edc411..17d39a6 100644
--- a/assets/javascripts/discourse/templates/admin/plugins-explorer-show.hbs
+++ b/assets/javascripts/discourse/templates/admin/plugins-explorer-show.hbs
@@ -1,21 +1,23 @@
-{{#if model}}
+{{#if selectedItem}}
{{#if editName}}
- {{text-field value=model.name}}
+ {{text-field value=selectedItem.name}}
{{else}}
-
{{model.name}}
+ {{selectedItem.name}}
{{d-button action="editName" icon="pencil" class="no-text"}}
{{/if}}
- {{#if editName}}
- {{textarea value=model.description}}
+ {{#if controller.editName}}
+ {{textarea value=selectedItem.description}}
{{else}}
- {{model.description}}
+ {{selectedItem.description}}
{{/if}}
- {{textarea value=model.sql}}
+ {{textarea value=selectedItem.sql}}
- {{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}}
diff --git a/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs b/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs
index 30fb60d..7258a55 100644
--- a/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs
+++ b/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs
@@ -22,9 +22,10 @@
- {{render "admin/plugins-explorer-show" selectedItem}}
+ {{partial "admin/plugins-explorer-show" model=selectedItem}}
+{{conditional-loading-spinner condition=loading}}
{{results}}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 6cbdba0..6812782 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -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"
diff --git a/config/locales/client.pl_PL.yml b/config/locales/client.pl_PL.yml
deleted file mode 100644
index 293ed49..0000000
--- a/config/locales/client.pl_PL.yml
+++ /dev/null
@@ -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 {{tag}}"
diff --git a/config/locales/client.ru.yml b/config/locales/client.ru.yml
deleted file mode 100644
index b60f592..0000000
--- a/config/locales/client.ru.yml
+++ /dev/null
@@ -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: "Темы с тегом {{tag}}"
diff --git a/config/locales/client.zh_CN.yml b/config/locales/client.zh_CN.yml
deleted file mode 100644
index 7f4010d..0000000
--- a/config/locales/client.zh_CN.yml
+++ /dev/null
@@ -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: "主题标签: {{tag}}"
diff --git a/config/locales/server.pl_PL.yml b/config/locales/server.pl_PL.yml
deleted file mode 100644
index 86b162a..0000000
--- a/config/locales/server.pl_PL.yml
+++ /dev/null
@@ -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"
diff --git a/config/locales/server.ru.yml b/config/locales/server.ru.yml
deleted file mode 100644
index 5438890..0000000
--- a/config/locales/server.ru.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-ru:
- site_settings:
- min_trust_to_create_tag: "Минимальный уровень доверия для создания тегов."
- max_tags_per_topic: "Максимальное количество тегов для темы."
diff --git a/config/locales/server.zh_CN.yml b/config/locales/server.zh_CN.yml
deleted file mode 100644
index 4749c80..0000000
--- a/config/locales/server.zh_CN.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-zh_CN:
- site_settings:
- tagging_enabled: "允许用户为主题设置标签?"
- min_trust_to_create_tag: "允许创建标签的最小信任等级"
- max_tags_per_topic: "一个主题最多允许被创建多少个标签"
- max_tag_length: "一个标签允许的最大字符数"