This repository has been archived by the owner on Jun 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fd-polymer-ispermitted.html
57 lines (52 loc) · 1.7 KB
/
fd-polymer-ispermitted.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../fd-polymer-api-settings/fd-polymer-api-settings.html">
<link rel="import" href="../fd-polymer-ws-service/fd-polymer-generic-ws.html">
<!--
Element providing a service for checking a user permission
##### Example
<fd-ispermitted permission="*:read">
This message is shown only if user has proper permissions.
</fd-ispermitted>
@element fd-ws-service
@blurb Element providing a service for checking a user permission
@status alpha
@homepage http://freedomotic.github.io/fd-polymer-ispermitted
-->
<polymer-element name="fd-ispermitted" extends="fd-generic-ws" attributes="permission allowed">
<template>
<template if="{{allowed}}">
<content></content>
</template>
</template>
<script>
Polymer("fd-ispermitted", {
/**
* The 'permission' attribute contains a string representing a Wildcard permission to check
*
* @attribute permission
* @type string
* @default undefined
*/
type: 'ispermitted',
auto: true,
allowed: false,
onMessage: function(e, det) {
if (det.permission == this.permission) {
// console.log("PERMISSION CHECK:", det);
this.allowed = det.allowed;
}
},
onOpen: function(e, self) {
this.send(this.permission);
},
permissionChanged: function() {
// console.log("NEWPERMISSION:", this.permission);
// console.log("SENDING ON PERMISSIONCHANGE", this.permission);
this.send(this.permission);
},
allowedChanged: function() {
// console.log(this.permission, " IS ", this.allowed);
}
});
</script>
</polymer-element>