Refactor gr-edit-constants
Renaming the 'key' prop in the GrEditConstants.Actions enum is more technically correct. The value is used as an ID in most applications, so this makes more sense when used practically. Change-Id: Ifb40bca2c71296289639d9f30835c2f871205175
This commit is contained in:
@@ -20,10 +20,10 @@ limitations under the License.
|
||||
const GrEditConstants = window.GrEditConstants || {};
|
||||
|
||||
GrEditConstants.Actions = {
|
||||
EDIT: {label: 'Edit', key: 'edit'},
|
||||
DELETE: {label: 'Delete', key: 'delete'},
|
||||
RENAME: {label: 'Rename', key: 'rename'},
|
||||
RESTORE: {label: 'Restore', key: 'restore'},
|
||||
EDIT: {label: 'Edit', id: 'edit'},
|
||||
DELETE: {label: 'Delete', id: 'delete'},
|
||||
RENAME: {label: 'Rename', id: 'rename'},
|
||||
RESTORE: {label: 'Restore', id: 'restore'},
|
||||
};
|
||||
|
||||
window.GrEditConstants = GrEditConstants;
|
||||
|
@@ -72,8 +72,8 @@ limitations under the License.
|
||||
</style>
|
||||
<template is="dom-repeat" items="[[_actions]]" as="action">
|
||||
<gr-button
|
||||
id$="[[action.key]]"
|
||||
class$="[[_computeIsInvisible(action.key, hiddenActions)]]"
|
||||
id$="[[action.id]]"
|
||||
class$="[[_computeIsInvisible(action.id, hiddenActions)]]"
|
||||
link
|
||||
on-tap="_handleTap">[[action.label]]</gr-button>
|
||||
</template>
|
||||
|
@@ -26,7 +26,7 @@
|
||||
*/
|
||||
hiddenActions: {
|
||||
type: Array,
|
||||
value() { return [GrEditConstants.Actions.RESTORE.key]; },
|
||||
value() { return [GrEditConstants.Actions.RESTORE.id]; },
|
||||
},
|
||||
|
||||
_actions: {
|
||||
@@ -57,16 +57,16 @@
|
||||
e.preventDefault();
|
||||
const action = Polymer.dom(e).localTarget.id;
|
||||
switch (action) {
|
||||
case GrEditConstants.Actions.EDIT.key:
|
||||
case GrEditConstants.Actions.EDIT.id:
|
||||
this.openEditDialog();
|
||||
return;
|
||||
case GrEditConstants.Actions.DELETE.key:
|
||||
case GrEditConstants.Actions.DELETE.id:
|
||||
this.openDeleteDialog();
|
||||
return;
|
||||
case GrEditConstants.Actions.RENAME.key:
|
||||
case GrEditConstants.Actions.RENAME.id:
|
||||
this.openRenameDialog();
|
||||
return;
|
||||
case GrEditConstants.Actions.RESTORE.key:
|
||||
case GrEditConstants.Actions.RESTORE.id:
|
||||
this.openRestoreDialog();
|
||||
return;
|
||||
}
|
||||
@@ -186,8 +186,8 @@
|
||||
}));
|
||||
},
|
||||
|
||||
_computeIsInvisible(key, hiddenActions) {
|
||||
return hiddenActions.includes(key) ? 'invisible' : '';
|
||||
_computeIsInvisible(id, hiddenActions) {
|
||||
return hiddenActions.includes(id) ? 'invisible' : '';
|
||||
},
|
||||
});
|
||||
})();
|
Reference in New Issue
Block a user