1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-28 17:49:41 +02:00

ember-truth-helpers, allow for no category viewers

This commit is contained in:
Harvey Kandola 2017-09-22 08:52:11 +01:00
parent 3a9675eb14
commit b56d3426d2
7 changed files with 20 additions and 12 deletions

View file

@ -310,8 +310,7 @@ func (h *Handler) GetSummary(w http.ResponseWriter, r *http.Request) {
} }
/* /*
- category view permission handling - filter users using account.users = true/false
- filter users using new permission
- link/unlink document to category - link/unlink document to category
- check print/pdf - check print/pdf
- filter space documents by category -- URL param? nested route? - filter space documents by category -- URL param? nested route?

View file

@ -330,6 +330,12 @@ func (h *Handler) SetCategoryPermissions(w http.ResponseWriter, r *http.Request)
return return
} }
spaceID := request.Query(r, "space")
if len(id) == 0 {
response.WriteMissingDataError(w, method, "space")
return
}
defer streamutil.Close(r.Body) defer streamutil.Close(r.Body)
body, err := ioutil.ReadAll(r.Body) body, err := ioutil.ReadAll(r.Body)
if err != nil { if err != nil {
@ -346,12 +352,6 @@ func (h *Handler) SetCategoryPermissions(w http.ResponseWriter, r *http.Request)
return return
} }
if len(model) == 0 {
response.WriteEmpty(w)
return
}
spaceID := model[0].SpaceID
if !HasPermission(ctx, *h.Store, spaceID, permission.SpaceManage, permission.SpaceOwner) { if !HasPermission(ctx, *h.Store, spaceID, permission.SpaceManage, permission.SpaceOwner) {
response.WriteForbiddenError(w) response.WriteForbiddenError(w)
return return

View file

@ -182,6 +182,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, DropdownMixin
}, },
onGrantAccess() { onGrantAccess() {
let folder = this.get('folder');
let category = this.get('currentCategory'); let category = this.get('currentCategory');
let users = this.get('categoryUsers').filterBy('selected', true); let users = this.get('categoryUsers').filterBy('selected', true);
let viewers = []; let viewers = [];
@ -200,7 +201,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, DropdownMixin
viewers.push(v); viewers.push(v);
}); });
this.get('categoryService').setViewers(category.get('id'), viewers).then(() => { this.get('categoryService').setViewers(folder.get('id'), category.get('id'), viewers).then(() => {
this.load(); this.load();
}); });

View file

@ -111,8 +111,8 @@ export default BaseService.extend({
}, },
// Save list of users who can see given category // Save list of users who can see given category
setViewers(categoryId, viewers) { setViewers(spaceId, categoryId, viewers) {
return this.get('ajax').request(`category/${categoryId}/permission`, { return this.get('ajax').request(`category/${categoryId}/permission?space=${spaceId}`, {
method: 'PUT', method: 'PUT',
contentType: 'json', contentType: 'json',
data: JSON.stringify(viewers) data: JSON.stringify(viewers)

View file

@ -16,7 +16,8 @@
{{else}} {{else}}
<div class="category"> <div class="category">
<div class="name">{{cat.category}}</div> <div class="name">{{cat.category}}</div>
<div class="info">{{cat.documents}} documents, {{cat.users}} people</div> <div class="info">
{{cat.documents}} {{if (eq cat.documents 1) 'document' 'documents' }}, {{cat.users}} {{if (eq cat.users 1) 'person' 'people' }}</div>
</div> </div>
{{/if}} {{/if}}
<div class="pull-right buttons"> <div class="pull-right buttons">

View file

@ -42,6 +42,7 @@
"ember-resolver": "^4.0.0", "ember-resolver": "^4.0.0",
"ember-simple-auth": "1.2.2", "ember-simple-auth": "1.2.2",
"ember-source": "~2.15.0", "ember-source": "~2.15.0",
"ember-truth-helpers": "^1.3.0",
"loader.js": "^4.2.3" "loader.js": "^4.2.3"
}, },
"ember-addon": { "ember-addon": {

View file

@ -2663,6 +2663,12 @@ ember-test-helpers@^0.6.3:
version "0.6.3" version "0.6.3"
resolved "https://registry.yarnpkg.com/ember-test-helpers/-/ember-test-helpers-0.6.3.tgz#f864cdf6f4e75f3f8768d6537785b5ab6e82d907" resolved "https://registry.yarnpkg.com/ember-test-helpers/-/ember-test-helpers-0.6.3.tgz#f864cdf6f4e75f3f8768d6537785b5ab6e82d907"
ember-truth-helpers@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/ember-truth-helpers/-/ember-truth-helpers-1.3.0.tgz#6ed9f83ce9a49f52bb416d55e227426339a64c60"
dependencies:
ember-cli-babel "^5.1.6"
ember-try-config@^2.0.1: ember-try-config@^2.0.1:
version "2.1.0" version "2.1.0"
resolved "https://registry.yarnpkg.com/ember-try-config/-/ember-try-config-2.1.0.tgz#e0e156229a542346a58ee6f6ad605104c98edfe0" resolved "https://registry.yarnpkg.com/ember-try-config/-/ember-try-config-2.1.0.tgz#e0e156229a542346a58ee6f6ad605104c98edfe0"