From 9ccd0fd19cabdc142d3d22d6e9870255c0bc0011 Mon Sep 17 00:00:00 2001 From: Harvey Kandola Date: Mon, 25 Sep 2017 11:52:26 +0100 Subject: [PATCH] document tag editor re-vamped --- domain/account/mysql/store.go | 20 +++++++------------ domain/section/github/github.go | 5 ----- domain/user/mysql/store.go | 2 +- gui/app/components/document/space-category.js | 7 +++++-- gui/app/components/document/tag-editor.js | 12 ++++++----- .../view/document/space-category-tag.scss | 18 +++++++---------- gui/app/styles/widget/widget-dropdown.scss | 2 +- .../components/document/space-category.hbs | 16 ++++++++++----- .../components/document/tag-editor.hbs | 20 ++++++++++++++----- 9 files changed, 54 insertions(+), 48 deletions(-) diff --git a/domain/account/mysql/store.go b/domain/account/mysql/store.go index fcc1ba98..54fba800 100644 --- a/domain/account/mysql/store.go +++ b/domain/account/mysql/store.go @@ -54,21 +54,14 @@ func (s Scope) Add(ctx domain.RequestContext, account account.Account) (err erro // GetUserAccount returns the database account record corresponding to the given userID, using the client's current organizaion. func (s Scope) GetUserAccount(ctx domain.RequestContext, userID string) (account account.Account, err error) { - stmt, err := s.Runtime.Db.Preparex(` -        SELECT a.id, a.refid, a.orgid, a.userid, a.editor, a.admin, a.active, a.created, a.revised, b.company, b.title, b.message, b.domain -        FROM account a, organization b -        WHERE b.refid=a.orgid and a.orgid=? and a.userid=?`) - defer streamutil.Close(stmt) + err = s.Runtime.Db.Get(&account, ` + SELECT a.id, a.refid, a.orgid, a.userid, a.editor, a.admin, a.active, a.created, a.revised, + b.company, b.title, b.message, b.domain + FROM account a, organization b + WHERE b.refid=a.orgid AND a.orgid=? AND a.userid=?`, ctx.OrgID, userID) - if err != nil { - err = errors.Wrap(err, fmt.Sprintf("prepare select for account by user %s", userID)) - return - } - - err = stmt.Get(&account, ctx.OrgID, userID) if err != sql.ErrNoRows && err != nil { err = errors.Wrap(err, fmt.Sprintf("execute select for account by user %s", userID)) - return } return @@ -92,7 +85,8 @@ func (s Scope) GetUserAccounts(ctx domain.RequestContext, userID string) (t []ac // GetAccountsByOrg returns a slice of database account records, for all users in the client's organization. func (s Scope) GetAccountsByOrg(ctx domain.RequestContext) (t []account.Account, err error) { err = s.Runtime.Db.Select(&t, - `SELECT a.id, a.refid, a.orgid, a.userid, a.editor, a.admin, a.active, a.created, a.revised, b.company, b.title, b.message, b.domain + `SELECT a.id, a.refid, a.orgid, a.userid, a.editor, a.admin, a.active, a.created, a.revised, + b.company, b.title, b.message, b.domain FROM account a, organization b WHERE a.orgid=b.refid AND a.orgid=? AND a.active=1`, ctx.OrgID) diff --git a/domain/section/github/github.go b/domain/section/github/github.go index 380f1cbe..b1c68639 100644 --- a/domain/section/github/github.go +++ b/domain/section/github/github.go @@ -153,7 +153,6 @@ func (p *Provider) Refresh(ctx *provider.Context, configJSON, data string) strin err := json.Unmarshal([]byte(configJSON), &c) if err != nil { - p.Runtime.Log.Error("unable to unmarshall github config", err) return "internal configuration error '" + err.Error() + "'" } @@ -164,7 +163,6 @@ func (p *Provider) Refresh(ctx *provider.Context, configJSON, data string) strin byts, err := json.Marshal(refreshReportData(&c, client)) if err != nil { - p.Runtime.Log.Error("unable to marshall github data", err) return "internal configuration error '" + err.Error() + "'" } @@ -188,9 +186,7 @@ func (p *Provider) Render(ctx *provider.Context, config, data string) string { var c = githubConfig{} err = json.Unmarshal([]byte(config), &c) - if err != nil { - p.Runtime.Log.Error("unable to unmarshall github config", err) return "Please delete and recreate this Github section." } @@ -206,7 +202,6 @@ func (p *Provider) Render(ctx *provider.Context, config, data string) string { err = json.Unmarshal([]byte(data), &payload) if err != nil { - p.Runtime.Log.Error("unable to unmarshall github data", err) return "Please delete and recreate this Github section." } diff --git a/domain/user/mysql/store.go b/domain/user/mysql/store.go index 3d0d5914..16f9a9ba 100644 --- a/domain/user/mysql/store.go +++ b/domain/user/mysql/store.go @@ -188,7 +188,7 @@ func (s Scope) GetUsersForOrganization(ctx domain.RequestContext) (u []user.User // GetSpaceUsers returns a slice containing all user records for given folder. func (s Scope) GetSpaceUsers(ctx domain.RequestContext, spaceID string) (u []user.User, err error) { err = s.Runtime.Db.Select(&u, ` - SELECT u.id, u.refid, u.firstname, u.lastname, u.email, u.initials, u.password, u.salt, u.reset, u.created, u.revised, u.global + SELECT u.id, u.refid, u.firstname, u.lastname, u.email, u.initials, u.password, u.salt, u.reset, u.created, u.revised, u.global, a.active, a.users AS viewusers, a.editor, a.admin FROM user u, account a WHERE a.orgid=? AND u.refid = a.userid AND a.active=1 AND u.refid IN ( diff --git a/gui/app/components/document/space-category.js b/gui/app/components/document/space-category.js index 1f63291a..55e2f33e 100644 --- a/gui/app/components/document/space-category.js +++ b/gui/app/components/document/space-category.js @@ -21,8 +21,11 @@ export default Ember.Component.extend(TooltipMixin, NotifierMixin, { hasCategories: Ember.computed('categories', function() { return this.get('categories').length > 0; }), - canAdd: Ember.computed('categories', function() { - return this.get('categories').length > 0 && this.get('permissions.documentEdit'); + canSelectCategory: Ember.computed('categories', function() { + return (this.get('categories').length > 0 && this.get('permissions.documentEdit')); + }), + canAddCategory: Ember.computed('categories', function() { + return this.get('permissions.spaceOwner') || this.get('permissions.spaceManage'); }), init() { diff --git a/gui/app/components/document/tag-editor.js b/gui/app/components/document/tag-editor.js index dc43b77a..0151ccf3 100644 --- a/gui/app/components/document/tag-editor.js +++ b/gui/app/components/document/tag-editor.js @@ -16,7 +16,10 @@ export default Ember.Component.extend({ tagz: [], newTag: "", maxTags: 3, - canAdd: false, + canAdd: false, + emptyState: Ember.computed('tagz', function() { + return (this.get('tagz').length === 0 && !this.get('permissions.documentEdit')); + }), init() { this._super(...arguments); @@ -36,15 +39,14 @@ export default Ember.Component.extend({ }, didUpdateAttrs() { + this._super(...arguments); this.set('canAdd', this.get('permissions.documentEdit') && this.get('tagz').get('length') < 3); }, - didInsertElement() { - - }, willDestroyElement() { - $("#add-tag-field").off("keydown"); + this._super(...arguments); + $("#add-tag-field").off("keydown"); }, actions: { diff --git a/gui/app/styles/view/document/space-category-tag.scss b/gui/app/styles/view/document/space-category-tag.scss index 95ad578d..667805b5 100644 --- a/gui/app/styles/view/document/space-category-tag.scss +++ b/gui/app/styles/view/document/space-category-tag.scss @@ -5,7 +5,7 @@ text-transform: uppercase; color: $color-gray; font-weight: bold; - font-size: 1rem; + font-size: 1.2rem; margin: 0 0 10px 0; } } @@ -22,7 +22,7 @@ text-transform: uppercase; color: $color-gray; font-weight: bold; - font-size: 1rem; + font-size: 1.2rem; margin: 0 0 10px 0; } } @@ -34,20 +34,16 @@ text-transform: uppercase; color: $color-gray; font-weight: bold; - font-size: 1rem; + font-size: 1.2rem; margin: 0 0 10px 0; } > .regular-button { margin-right: 10px; + } - &:hover { - visibility: visible; - } - - > .material-icons { - visibility: hidden; - } + > .none { + color: $color-gray; + font-size: 0.9rem; } } - diff --git a/gui/app/styles/widget/widget-dropdown.scss b/gui/app/styles/widget/widget-dropdown.scss index 213d8ee6..546f0894 100644 --- a/gui/app/styles/widget/widget-dropdown.scss +++ b/gui/app/styles/widget/widget-dropdown.scss @@ -35,7 +35,7 @@ line-height: 1.5em; > .dropdown-dialog { - @extend .clearfix; + @extend .clearfix; .content { > p { diff --git a/gui/app/templates/components/document/space-category.hbs b/gui/app/templates/components/document/space-category.hbs index a03e281c..e9bcc620 100644 --- a/gui/app/templates/components/document/space-category.hbs +++ b/gui/app/templates/components/document/space-category.hbs @@ -13,18 +13,24 @@ {{#each selectedCategories as |cat|}}
{{cat.category}}
+ {{else}} + {{#if canAddCategory}} + {{#link-to 'folder.settings.category' folder.id folder.slug}}Manage{{/link-to}} + {{else}} +

 

+ {{/if}} {{/each}} - {{#if hasCategories}} + {{#if canSelectCategory}}
add
- {{#dropdown-dialog target="document-category-button" position="bottom left" button="set" color="flat-green" onAction=(action 'onSave')}} -

Select categories for document

+

Set document categories

{{ui/ui-list-picker items=categories nameField='category'}} + {{#if canAddCategory}} + {{#link-to 'folder.settings.category' folder.id folder.slug}}Manage{{/link-to}} + {{/if}} {{/dropdown-dialog}} - {{else}} -

 

{{/if}} diff --git a/gui/app/templates/components/document/tag-editor.hbs b/gui/app/templates/components/document/tag-editor.hbs index 0bd857e7..359daa98 100644 --- a/gui/app/templates/components/document/tag-editor.hbs +++ b/gui/app/templates/components/document/tag-editor.hbs @@ -1,13 +1,13 @@
Tag
- {{#each tagz as |tg|}} -
{{concat '#' tg}}
+ {{#each tagz as |t index|}} +
{{concat '#' t}}
{{/each}} {{#if canAdd}} -
- + +
+ add
- {{#dropdown-dialog target="add-tag-button" position="bottom left" button="Add" color="flat-green" onAction=(action 'addTag') focusOn="add-tag-field" onOpenCallback=(action 'onTagEditor') targetOffset="20px 0"}} + {{#dropdown-dialog tagName="span" target="document-tag-button" position="bottom left" button="Add" color="flat-green" onAction=(action 'addTag') focusOn="add-tag-field" onOpenCallback=(action 'onTagEditor') targetOffset="20px 0"}}
Lowercase letters, numbers, dashes
@@ -15,4 +15,14 @@
{{/dropdown-dialog}} {{/if}} + {{#if permissions.documentEdit}} + {{#each tagz as |t index|}} + {{#dropdown-dialog target=(concat 'delete-tag-' index) position="bottom left" button="Delete" color="flat-red" onAction=(action 'removeTag' t)}} +

Are you sure you want delete this tag?

+ {{/dropdown-dialog}} + {{/each}} + {{/if}} + {{#if emptyState}} +
none
+ {{/if}}