diff --git a/app/app/components/section/gemini/type-editor.js b/app/app/components/section/gemini/type-editor.js index ca307e83..14a265b9 100644 --- a/app/app/components/section/gemini/type-editor.js +++ b/app/app/components/section/gemini/type-editor.js @@ -12,8 +12,9 @@ import Ember from 'ember'; import NotifierMixin from '../../../mixins/notifier'; import TooltipMixin from '../../../mixins/tooltip'; +import SectionMixin from '../../../mixins/section'; -export default Ember.Component.extend(NotifierMixin, TooltipMixin, { +export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, { sectionService: Ember.inject.service('section'), isDirty: false, waiting: false, @@ -22,14 +23,6 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { workspaces: [], config: {}, - fieldEditable: function() { - if (this.get('page.userId') !== this.session.user.id) { - return "readonly"; - } else { - return undefined; - } - }.property('config'), - didReceiveAttrs() { let config = {}; diff --git a/app/app/components/section/trello/type-editor.js b/app/app/components/section/trello/type-editor.js index ba0c3ae4..fb5ebaed 100644 --- a/app/app/components/section/trello/type-editor.js +++ b/app/app/components/section/trello/type-editor.js @@ -1,11 +1,11 @@ // Copyright 2016 Documize Inc. . All rights reserved. // -// This software (Documize Community Edition) is licensed under +// This software (Documize Community Edition) is licensed under // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html // // You can operate outside the AGPL restrictions by purchasing // Documize Enterprise Edition and obtaining a commercial license -// by contacting . +// by contacting . // // https://documize.com @@ -13,11 +13,12 @@ import Ember from 'ember'; import NotifierMixin from '../../../mixins/notifier'; import TooltipMixin from '../../../mixins/tooltip'; +import SectionMixin from '../../../mixins/section'; -export default Ember.Component.extend(NotifierMixin, TooltipMixin, { +export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, { sectionService: Ember.inject.service('section'), isDirty: false, - waiting: false, + busy: false, authenticated: false, config: {}, boards: null, @@ -42,6 +43,8 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { if (this.get('config.appKey') !== "" && this.get('config.token') !== "") { + console.log(this.get('isReadonly')); + console.log(this.get('isMine')); this.send('auth'); } }, @@ -51,12 +54,14 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { }, getBoardLists() { + this.set('busy', true); + let self = this; let boards = this.get('boards'); let board = this.get('config.board'); - this.set('waiting', true); + let page = this.get('page'); - if (is.null(board)) { + if (is.null(board) || is.undefined(board)) { if (boards.length) { board = boards[0]; this.set('config.board', board); @@ -65,9 +70,9 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { this.set('config.board', boards.findBy('id', board.id)); } - Trello.get(`boards/${board.id}/lists/open?fields=id,name,url`, - function(lists) { - let savedLists = self.get('config.lists'); + this.get('sectionService').fetch(page, "lists", self.get('config')) + .then(function(lists) { + let savedLists = self.get('config.lists'); if (savedLists === null) { savedLists = []; } @@ -82,14 +87,40 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { }); self.set('config.lists', lists); - self.set('waiting', false); - }, - function(error) { - self.set('waiting', false); + self.set('busy', false); + }, function(error) { //jshint ignore: line + self.set('busy', false); self.set('authenticated', false); self.showNotification("Unable to fetch board lists"); console.log(error); - }); + }); + + + // Trello.get(`boards/${board.id}/lists/open?fields=id,name,url`, + // function(lists) { + // let savedLists = self.get('config.lists'); + // if (savedLists === null) { + // savedLists = []; + // } + // + // lists.forEach(function(list) { + // let saved = savedLists.findBy("id", list.id); + // let included = true; + // if (is.not.undefined(saved)) { + // included = saved.included; + // } + // list.included = included; + // }); + // + // self.set('config.lists', lists); + // self.set('busy', false); + // }, + // function(error) { + // self.set('busy', false); + // self.set('authenticated', false); + // self.showNotification("Unable to fetch board lists"); + // console.log(error); + // }); }, actions: { @@ -124,7 +155,9 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { } let self = this; - self.set('waiting', true); + let page = this.get('page'); + + self.set('busy', true); Ember.$.getScript("https://api.trello.com/1/client.js?key=" + this.get('config.appKey'), function() { Trello.authorize({ @@ -140,24 +173,36 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { success: function() { self.set('authenticated', true); self.set('config.token', Trello.token()); - self.set('waiting', true); + self.set('busy', true); - Trello.get("members/me/boards?fields=id,name,url,closed,prefs,idOrganization", - function(boards) { - self.set('waiting', false); + self.get('sectionService').fetch(page, "boards", self.get('config')) + .then(function(boards) { + self.set('busy', false); self.set('boards', boards.filterBy("closed", false)); self.getBoardLists(); - }, - function(error) { - self.set('waiting', false); + }, function(error) { //jshint ignore: line + self.set('busy', false); self.set('authenticated', false); self.showNotification("Unable to fetch boards"); console.log(error); - } - ); + }); + + // Trello.get("members/me/boards?fields=id,name,url,closed,prefs,idOrganization", + // function(boards) { + // self.set('busy', false); + // self.set('boards', boards.filterBy("closed", false)); + // self.getBoardLists(); + // }, + // function(error) { + // self.set('busy', false); + // self.set('authenticated', false); + // self.showNotification("Unable to fetch boards"); + // console.log(error); + // } + // ); }, error: function(error) { - self.set('waiting', false); + self.set('busy', false); self.set('authenticated', false); self.showNotification("Unable to authenticate"); console.log(error); @@ -178,7 +223,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { }, onAction(title) { - this.set('waiting', false); + this.set('busy', true); let self = this; let page = this.get('page'); @@ -191,12 +236,15 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { this.get('sectionService').fetch(page, "cards", this.get('config')) .then(function(response) { meta.set('rawBody', JSON.stringify(response)); - self.set('waiting', false); + self.set('busy', false); self.attrs.onAction(page, meta); }, function(reason) { //jshint ignore: line - self.set('waiting', false); + self.set('busy', false); self.attrs.onAction(page, meta); }); } } -}); \ No newline at end of file +}); + +// show who owner is -- logout +// key really required? diff --git a/app/app/initializers/session.js b/app/app/initializers/session.js index 0350dbd8..55bb0999 100644 --- a/app/app/initializers/session.js +++ b/app/app/initializers/session.js @@ -13,6 +13,7 @@ export function initialize(application) { application.inject('route', 'session', 'service:session'); application.inject('controller', 'session', 'service:session'); application.inject('component', 'session', 'service:session'); + application.inject('mixin', 'session', 'service:session'); } export default { diff --git a/app/app/mixins/section.js b/app/app/mixins/section.js new file mode 100644 index 00000000..e40a6209 --- /dev/null +++ b/app/app/mixins/section.js @@ -0,0 +1,26 @@ +// Copyright 2016 Documize Inc. . All rights reserved. +// +// This software (Documize Community Edition) is licensed under +// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html +// +// You can operate outside the AGPL restrictions by purchasing +// Documize Enterprise Edition and obtaining a commercial license +// by contacting . +// +// https://documize.com + +import Ember from 'ember'; + +export default Ember.Mixin.create({ + isReadonly: function() { + if (this.get('page.userId') !== this.session.user.id) { + return "readonly"; + } else { + return undefined; + } + }.property('page'), + + isMine: function() { + return this.get('page.userId') !== this.session.user.id; + }.property('page') +}); \ No newline at end of file diff --git a/app/app/styles/widget/widget-input.scss b/app/app/styles/widget/widget-input.scss index f5e6a672..54e4eed2 100644 --- a/app/app/styles/widget/widget-input.scss +++ b/app/app/styles/widget/widget-input.scss @@ -53,7 +53,7 @@ padding: 5px; border: 1px solid $color-input; border-radius: 2px; - height: 2rem; + height: 2.3rem; font-size: 1rem; display: inline-block; diff --git a/app/app/templates/components/section/gemini/type-editor.hbs b/app/app/templates/components/section/gemini/type-editor.hbs index 40553fe8..47c484d1 100644 --- a/app/app/templates/components/section/gemini/type-editor.hbs +++ b/app/app/templates/components/section/gemini/type-editor.hbs @@ -47,17 +47,17 @@
e.g. http://helpdesk.countersoft.com
- {{focus-input id="gemini-url" type="text" value=config.url readonly=fieldEditable}} + {{focus-input id="gemini-url" type="text" value=config.url readonly=isReadonly}}
Gemini username
- {{input id="gemini-username" type="text" value=config.username readonly=fieldEditable}} + {{input id="gemini-username" type="text" value=config.username readonly=isReadonly}}
Gemini user API key (from user profile)
- {{input id="gemini-apikey" type="password" value=config.APIKey readonly=fieldEditable}} + {{input id="gemini-apikey" type="password" value=config.APIKey readonly=isReadonly}}
Authenticate
diff --git a/app/app/templates/components/section/trello/type-editor.hbs b/app/app/templates/components/section/trello/type-editor.hbs index 7666f4a0..1a1602a4 100644 --- a/app/app/templates/components/section/trello/type-editor.hbs +++ b/app/app/templates/components/section/trello/type-editor.hbs @@ -32,7 +32,7 @@ } -{{#section/base-editor document=document folder=folder page=page busy=waiting tip="Trello is the visual way to manage your projects and organize anything (https://trello.com)" isDirty=(action 'isDirty') onCancel=(action 'onCancel') onAction=(action 'onAction')}} +{{#section/base-editor document=document folder=folder page=page busy=busy tip="Trello is the visual way to manage your projects and organize anything (https://trello.com)" isDirty=(action 'isDirty') onCancel=(action 'onCancel') onAction=(action 'onAction')}}
@@ -72,7 +72,8 @@ action=(action 'onBoardChange') optionValuePath="id" optionLabelPath="name" - selection=config.board}} + selection=config.board + readonly=isReadonly}}
diff --git a/app/app/templates/components/ui-select.hbs b/app/app/templates/components/ui-select.hbs index 33ce913c..a5c2e767 100644 --- a/app/app/templates/components/ui-select.hbs +++ b/app/app/templates/components/ui-select.hbs @@ -1,4 +1,4 @@ - {{#if prompt}}
- {{end}} + {{end}}
{{end}} @@ -334,10 +444,4 @@ const trelloTemplate = ` /* does server side load up all data? YES!!?? -owner read-only control? - -is appKey is global? - - where stored? - - how access? - - does section.go ask config to give us saved json */