150 lines
4.6 KiB
HTML
150 lines
4.6 KiB
HTML
<link rel="import" href="../polymer/polymer.html">
|
|
|
|
<link rel="import" href="../iron-ajax/iron-ajax.html">
|
|
<link rel="import" href="../iron-pages/iron-pages.html">
|
|
<link rel="import" href="../iron-icons/iron-icons.html">
|
|
|
|
<link rel="import" href="../paper-styles/color.html">
|
|
|
|
<link rel="import" href="../paper-material/paper-material.html">
|
|
<link rel="import" href="../paper-dialog/paper-dialog.html">
|
|
<link rel="import" href="../paper-input/paper-input.html">
|
|
<link rel="import" href="../paper-button/paper-button.html">
|
|
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
|
|
|
|
<link rel="import" href="../paper-dropdown-menu/paper-dropdown-menu.html">
|
|
<link rel="import" href="../paper-item/paper-item.html">
|
|
<link rel="import" href="../paper-listbox/paper-listbox.html">
|
|
|
|
<link rel="import" href="../paper-tabs/paper-tabs.html">
|
|
|
|
<link rel="import" href="../strolch-wc-styles/strolch-wc-styles.html">
|
|
|
|
<link rel="import" href="strolch-wc-inspector-behavior.html">
|
|
<link rel="import" href="strolch-wc-role-privilege.html">
|
|
|
|
<dom-module id="strolch-wc-role">
|
|
|
|
<template>
|
|
|
|
<style is="strolch-wc-styles">
|
|
|
|
:host {
|
|
display: block;
|
|
margin: 0;
|
|
padding: 0;
|
|
height: 100%;
|
|
}
|
|
|
|
paper-material {
|
|
background-color: white;
|
|
}
|
|
|
|
</style>
|
|
|
|
<paper-material elevation="1">
|
|
<h3 class="g-m-3 g-p-2" on-tap="_toggleOpened">
|
|
<template is="dom-if" if="[[!opened]]">
|
|
<paper-icon-button icon="arrow-drop-down"></paper-icon-button>
|
|
</template>
|
|
<template is="dom-if" if="[[opened]]">
|
|
<paper-icon-button icon="arrow-drop-up"></paper-icon-button>
|
|
</template>
|
|
[[role.name]]
|
|
</h3>
|
|
|
|
<template is="dom-if" if="[[opened]]">
|
|
<template is="dom-repeat" items="[[role.privileges]]" as="privilege">
|
|
<strolch-wc-role-privilege base-path="[[basePath]]"
|
|
role="[[role]]"
|
|
privilege="[[privilege]]"></strolch-wc-role-privilege>
|
|
</template>
|
|
|
|
|
|
<paper-button on-tap="reload" autofocus>Cancel</paper-button>
|
|
<paper-button on-tap="_addOrUpdateRole">Save</paper-button>
|
|
|
|
</template>
|
|
|
|
</paper-material>
|
|
|
|
<iron-ajax id="ajax"
|
|
content-type="application/json"
|
|
handle-as="json"
|
|
on-response="_handleAjaxResponse"
|
|
on-error="onAjaxError"></iron-ajax>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
Polymer({
|
|
|
|
is: 'strolch-wc-role',
|
|
|
|
behaviors: [
|
|
StrolchInspectorBehavior
|
|
],
|
|
|
|
properties: {
|
|
opened: {
|
|
type: Boolean,
|
|
value: false
|
|
},
|
|
role: {
|
|
type: Object
|
|
},
|
|
isNew: {
|
|
type: Boolean
|
|
}
|
|
},
|
|
|
|
listeners: {},
|
|
|
|
ready: function () {
|
|
//
|
|
},
|
|
|
|
reload: function () {
|
|
|
|
this.dlgTitle = 'Role query failed';
|
|
this._handleAjaxResponse = function (data) {
|
|
this.role = data.detail.response;
|
|
};
|
|
|
|
this.$.ajax.url = this.basePath + 'rest/strolch/privilege/roles/' + this.role.name;
|
|
this.$.ajax.method = 'GET';
|
|
this.$.ajax.generateRequest();
|
|
},
|
|
|
|
_handleAjaxResponse: function (evt) {
|
|
console.log('NOT YET DEFINED!');
|
|
},
|
|
|
|
_toggleOpened: function (e) {
|
|
this.opened = !this.opened;
|
|
},
|
|
|
|
_addOrUpdateRole: function (e) {
|
|
|
|
this.dlgTitle = 'Save role failed';
|
|
this._handleAjaxResponse = function (data) {
|
|
this.fire('strolch-role-reload-needed');
|
|
};
|
|
|
|
if (this.isNew) {
|
|
this.$.ajax.url = this.basePath + 'rest/strolch/privilege/roles';
|
|
this.$.ajax.method = 'POST';
|
|
} else {
|
|
this.$.ajax.url = this.basePath + 'rest/strolch/privilege/roles/' + this.role.name;
|
|
this.$.ajax.method = 'PUT';
|
|
}
|
|
this.$.ajax.body = this.role;
|
|
this.$.ajax.generateRequest();
|
|
}
|
|
});
|
|
|
|
</script>
|
|
|
|
</dom-module>
|