-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add permission support for menu items (#17263)
- Loading branch information
1 parent
022aaf9
commit abbd3e8
Showing
39 changed files
with
758 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/OrchardCore.Modules/OrchardCore.Menu/Assets/js/menu-permission-picker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
function initMenuPermissionsPicker(element) { | ||
// only run script if element exists | ||
if (element) { | ||
var elementId = element.id; | ||
var selectedItems = JSON.parse(element.dataset.selectedItems || "[]"); | ||
var allItems = JSON.parse(element.dataset.allItems || "[]"); | ||
|
||
var vueMultiselect = Vue.component('vue-multiselect', window.VueMultiselect.default); | ||
|
||
var vm = new Vue({ | ||
el: '#' + elementId, | ||
components: { 'vue-multiselect': vueMultiselect }, | ||
data: { | ||
value: null, | ||
arrayOfItems: selectedItems, | ||
options: allItems, | ||
}, | ||
computed: { | ||
selectedNames: function () { | ||
return this.arrayOfItems.map(function (x) { return x.name }).join(','); | ||
} | ||
}, | ||
methods: { | ||
onSelect: function (selectedOption, name) { | ||
var self = this; | ||
|
||
for (i = 0; i < self.arrayOfItems.length; i++) { | ||
if (self.arrayOfItems[i].name === selectedOption.name) { | ||
return; | ||
} | ||
} | ||
|
||
self.arrayOfItems.push(selectedOption); | ||
}, | ||
remove: function (item) { | ||
this.arrayOfItems.splice(this.arrayOfItems.indexOf(item), 1) | ||
} | ||
} | ||
}) | ||
|
||
/*Hook for other scripts that might want to have access to the view model*/ | ||
var event = new CustomEvent("menu-permission-picker-created", { detail: { vm: vm } }); | ||
document.querySelector("body").dispatchEvent(event); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/OrchardCore.Modules/OrchardCore.Menu/Assets/scss/menu-permission-picker.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.vue-multiselect .multiselect--active { | ||
z-index: var(--bs-dropdown-zindex, 1000); | ||
} | ||
|
||
[v-cloak] { | ||
display: none; | ||
} |
Oops, something went wrong.