1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-22 14:49:42 +02:00

document tag editor re-vamped

This commit is contained in:
Harvey Kandola 2017-09-25 11:52:26 +01:00
parent d6e18b4289
commit 9ccd0fd19c
9 changed files with 54 additions and 48 deletions

View file

@ -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. // 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) { func (s Scope) GetUserAccount(ctx domain.RequestContext, userID string) (account account.Account, err error) {
stmt, err := s.Runtime.Db.Preparex(` 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 SELECT a.id, a.refid, a.orgid, a.userid, a.editor, a.admin, a.active, a.created, a.revised,
        FROM account a, organization b b.company, b.title, b.message, b.domain
        WHERE b.refid=a.orgid and a.orgid=? and a.userid=?`) FROM account a, organization b
defer streamutil.Close(stmt) 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 { if err != sql.ErrNoRows && err != nil {
err = errors.Wrap(err, fmt.Sprintf("execute select for account by user %s", userID)) err = errors.Wrap(err, fmt.Sprintf("execute select for account by user %s", userID))
return
} }
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. // 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) { func (s Scope) GetAccountsByOrg(ctx domain.RequestContext) (t []account.Account, err error) {
err = s.Runtime.Db.Select(&t, 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 FROM account a, organization b
WHERE a.orgid=b.refid AND a.orgid=? AND a.active=1`, ctx.OrgID) WHERE a.orgid=b.refid AND a.orgid=? AND a.active=1`, ctx.OrgID)

View file

@ -153,7 +153,6 @@ func (p *Provider) Refresh(ctx *provider.Context, configJSON, data string) strin
err := json.Unmarshal([]byte(configJSON), &c) err := json.Unmarshal([]byte(configJSON), &c)
if err != nil { if err != nil {
p.Runtime.Log.Error("unable to unmarshall github config", err)
return "internal configuration error '" + err.Error() + "'" 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)) byts, err := json.Marshal(refreshReportData(&c, client))
if err != nil { if err != nil {
p.Runtime.Log.Error("unable to marshall github data", err)
return "internal configuration error '" + err.Error() + "'" return "internal configuration error '" + err.Error() + "'"
} }
@ -188,9 +186,7 @@ func (p *Provider) Render(ctx *provider.Context, config, data string) string {
var c = githubConfig{} var c = githubConfig{}
err = json.Unmarshal([]byte(config), &c) err = json.Unmarshal([]byte(config), &c)
if err != nil { if err != nil {
p.Runtime.Log.Error("unable to unmarshall github config", err)
return "Please delete and recreate this Github section." 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) err = json.Unmarshal([]byte(data), &payload)
if err != nil { if err != nil {
p.Runtime.Log.Error("unable to unmarshall github data", err)
return "Please delete and recreate this Github section." return "Please delete and recreate this Github section."
} }

View file

@ -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. // 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) { func (s Scope) GetSpaceUsers(ctx domain.RequestContext, spaceID string) (u []user.User, err error) {
err = s.Runtime.Db.Select(&u, ` 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 a.active, a.users AS viewusers, a.editor, a.admin
FROM user u, account a FROM user u, account a
WHERE a.orgid=? AND u.refid = a.userid AND a.active=1 AND u.refid IN ( WHERE a.orgid=? AND u.refid = a.userid AND a.active=1 AND u.refid IN (

View file

@ -21,8 +21,11 @@ export default Ember.Component.extend(TooltipMixin, NotifierMixin, {
hasCategories: Ember.computed('categories', function() { hasCategories: Ember.computed('categories', function() {
return this.get('categories').length > 0; return this.get('categories').length > 0;
}), }),
canAdd: Ember.computed('categories', function() { canSelectCategory: Ember.computed('categories', function() {
return this.get('categories').length > 0 && this.get('permissions.documentEdit'); 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() { init() {

View file

@ -16,7 +16,10 @@ export default Ember.Component.extend({
tagz: [], tagz: [],
newTag: "", newTag: "",
maxTags: 3, maxTags: 3,
canAdd: false, canAdd: false,
emptyState: Ember.computed('tagz', function() {
return (this.get('tagz').length === 0 && !this.get('permissions.documentEdit'));
}),
init() { init() {
this._super(...arguments); this._super(...arguments);
@ -36,15 +39,14 @@ export default Ember.Component.extend({
}, },
didUpdateAttrs() { didUpdateAttrs() {
this._super(...arguments);
this.set('canAdd', this.get('permissions.documentEdit') && this.get('tagz').get('length') < 3); this.set('canAdd', this.get('permissions.documentEdit') && this.get('tagz').get('length') < 3);
}, },
didInsertElement() {
},
willDestroyElement() { willDestroyElement() {
$("#add-tag-field").off("keydown"); this._super(...arguments);
$("#add-tag-field").off("keydown");
}, },
actions: { actions: {

View file

@ -5,7 +5,7 @@
text-transform: uppercase; text-transform: uppercase;
color: $color-gray; color: $color-gray;
font-weight: bold; font-weight: bold;
font-size: 1rem; font-size: 1.2rem;
margin: 0 0 10px 0; margin: 0 0 10px 0;
} }
} }
@ -22,7 +22,7 @@
text-transform: uppercase; text-transform: uppercase;
color: $color-gray; color: $color-gray;
font-weight: bold; font-weight: bold;
font-size: 1rem; font-size: 1.2rem;
margin: 0 0 10px 0; margin: 0 0 10px 0;
} }
} }
@ -34,20 +34,16 @@
text-transform: uppercase; text-transform: uppercase;
color: $color-gray; color: $color-gray;
font-weight: bold; font-weight: bold;
font-size: 1rem; font-size: 1.2rem;
margin: 0 0 10px 0; margin: 0 0 10px 0;
} }
> .regular-button { > .regular-button {
margin-right: 10px; margin-right: 10px;
}
&:hover { > .none {
visibility: visible; color: $color-gray;
} font-size: 0.9rem;
> .material-icons {
visibility: hidden;
}
} }
} }

View file

@ -35,7 +35,7 @@
line-height: 1.5em; line-height: 1.5em;
> .dropdown-dialog { > .dropdown-dialog {
@extend .clearfix; @extend .clearfix;
.content { .content {
> p { > p {

View file

@ -13,18 +13,24 @@
{{#each selectedCategories as |cat|}} {{#each selectedCategories as |cat|}}
<div class="regular-button button-blue">{{cat.category}}</div> <div class="regular-button button-blue">{{cat.category}}</div>
{{else}}
{{#if canAddCategory}}
{{#link-to 'folder.settings.category' folder.id folder.slug}}Manage{{/link-to}}
{{else}}
<p>&nbsp;</p>
{{/if}}
{{/each}} {{/each}}
{{#if hasCategories}} {{#if canSelectCategory}}
<div class="regular-button button-white" id="document-category-button"> <div class="regular-button button-white" id="document-category-button">
<i class="material-icons">add</i> <i class="material-icons">add</i>
</div> </div>
{{#dropdown-dialog target="document-category-button" position="bottom left" button="set" color="flat-green" onAction=(action 'onSave')}} {{#dropdown-dialog target="document-category-button" position="bottom left" button="set" color="flat-green" onAction=(action 'onSave')}}
<p class="heading">Select categories for document</p> <p class="heading">Set document categories</p>
{{ui/ui-list-picker items=categories nameField='category'}} {{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}} {{/dropdown-dialog}}
{{else}}
<p>&nbsp;</p>
{{/if}} {{/if}}
</div> </div>

View file

@ -1,13 +1,13 @@
<div class="document-tags"> <div class="document-tags">
<div class="caption">Tag</div> <div class="caption">Tag</div>
{{#each tagz as |tg|}} {{#each tagz as |t index|}}
<div class="regular-button button-chip">{{concat '#' tg}}</div> <div class="regular-button button-chip" id="{{concat 'delete-tag-' index}}">{{concat '#' t}}</div>
{{/each}} {{/each}}
{{#if canAdd}} {{#if canAdd}}
<div class="chip-action"> <div class="regular-button button-white" id="document-tag-button">
<span id="add-tag-button" class="chip-text">+</span> <i class="material-icons">add</i>
</div> </div>
{{#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"}}
<div class="input-control"> <div class="input-control">
<label>Tag</label> <label>Tag</label>
<div class="tip">Lowercase letters, numbers, dashes</div> <div class="tip">Lowercase letters, numbers, dashes</div>
@ -15,4 +15,14 @@
</div> </div>
{{/dropdown-dialog}} {{/dropdown-dialog}}
{{/if}} {{/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)}}
<p>Are you sure you want delete this tag?</p>
{{/dropdown-dialog}}
{{/each}}
{{/if}}
{{#if emptyState}}
<div class="none">none</div>
{{/if}}
</div> </div>