Skip to content

Commit

Permalink
remove my self as admin of organization
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexrdz committed Feb 13, 2018
1 parent 0cf4f80 commit 8d12c5d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/editors/organization-editor/organization-editor-styles.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
--paper-input-container-color: var(--vientos-tertiary-2);
}

paper-icon-button[icon="vientos:delete"] {
border: solid 2px var(--vientos-grey);
color: var(--vientos-grey);
padding: 1px 4px;
}

paper-icon-button[disabled] {
opacity: 0.4;
}


</style>

</template>
Expand Down
5 changes: 4 additions & 1 deletion app/editors/organization-editor/organization-editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@
</section>
<section id="admins">
<h3>[[localize('label:admins')]]</h3>
<ul class="admin-list">
<ul class="admin-list selection-list">
<template is="dom-repeat" items="[[admins]]">
<li>
<template is="dom-if" if="[[_mySelf(person, item)]]">
<paper-icon-button icon="vientos:delete" raised on-tap="_removeMySelfAsAdmin" disabled="[[_singleAdmin(admins)]]"></paper-icon-button>
</template>
<iron-image src="[[_getThumbnailUrl(item, 26)]]" sizing="cover"></iron-image>
[[item.name]]
</li>
Expand Down
18 changes: 18 additions & 0 deletions app/editors/organization-editor/organization-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class OrganizationEditor extends Polymer.mixinBehaviors(
type: Array,
statePath: 'places'
},
person: {
type: Array,
statePath: 'person'
},
people: {
type: Array,
statePath: 'people'
Expand Down Expand Up @@ -262,5 +266,19 @@ class OrganizationEditor extends Polymer.mixinBehaviors(
_imagePicked (e) {
this.set('newImage', e.detail)
}

_mySelf (person, admin) {
if (!person) return
return person._id === admin._id
}

_removeMySelfAsAdmin (e) {
this.set('updated.admins', this.updated.admins.filter(l => l !== e.model.item._id))
}

_singleAdmin (admins) {
if (!admins || !admins.length) return
return admins.length === 1
}
}
window.customElements.define(OrganizationEditor.is, OrganizationEditor)

0 comments on commit 8d12c5d

Please sign in to comment.