diff --git a/appinfo/routes.php b/appinfo/routes.php index 3e38267..31455ab 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -10,6 +10,8 @@ return [ ['name' => 'resource#update', 'url' => '/resources/{resourceId}', 'verb' => 'PUT'], ['name' => 'resource_member#index', 'url' => '/resources/{resourceId}/members', 'verb' => 'GET'], ['name' => 'resource_member#create', 'url' => '/resources/{resourceId}/members', 'verb' => 'POST'], + ['name' => 'resource_member#update', 'url' => '/resources/members/{id}', 'verb' => 'PUT'], + ['name' => 'resource_member#destroy', 'url' => '/resources/members/{id}', 'verb' => 'DELETE'], ['name' => 'organization#getOrganizationProviders', 'url' => '/organizationProviders', 'verb' => 'GET'], ['name' => 'organization#getOrganization', 'url' => '/organizationProviders/{organizationProviderId}/organizations/{organizationId}', 'verb' => 'GET'], ['name' => 'organization#getSubOrganizations', 'url' => '/organizationProviders/{organizationProviderId}/organizations/{parentOrganizationId}/subOrganizations', 'verb' => 'GET'], diff --git a/src/api.js b/src/api.js index 0ea8dc9..03835b5 100644 --- a/src/api.js +++ b/src/api.js @@ -118,14 +118,22 @@ export default { }, /** - * @param {number|string} resourceMemberId Resource member id + * @param {number} resourceMemberId Resource member id * @param {{ * permissionLevel: ResourceMemberPermissionLevel - * }} createResourceMemberDto CreateResourceMemberDto + * }} updateResourceMemberDto UpdateResourceMemberDto * @return {Promise} */ - updateResourceMember(resourceId, createResourceMemberDto) { - return axios.post(`/resources/${resourceId}/members`, { ...createResourceMemberDto }).then((res) => res.data); + updateResourceMember(resourceMemberId, updateResourceMemberDto) { + return axios.put(`/resources/members/${resourceMemberId}`, { ...updateResourceMemberDto }).then((res) => res.data); + }, + + /** + * @param {number} resourceMemberId Resource member id + * @return {Promise} + */ + deleteResourceMember(resourceMemberId) { + return axios.delete(`/resources/members/${resourceMemberId}`, {}).then((res) => res.data); }, /** diff --git a/src/components/MemberList/MemberList.vue b/src/components/MemberList/MemberList.vue deleted file mode 100644 index e5ea008..0000000 --- a/src/components/MemberList/MemberList.vue +++ /dev/null @@ -1,162 +0,0 @@ - - - - - diff --git a/src/components/MemberList/MemberListItem.vue b/src/components/MemberList/MemberListItem.vue index 5159991..23430d9 100644 --- a/src/components/MemberList/MemberListItem.vue +++ b/src/components/MemberList/MemberListItem.vue @@ -13,23 +13,23 @@ const props = defineProps({ }, }); -const friendlyNameParts = computed(() => props.member.principal.split(" / ")); +const friendlyNameParts = computed(() => [props.member.principal.id] /*.split(" / ")*/); const emit = defineEmits(["update", "delete"]); -const typeOptions = [ +const permissionLevelOptions = [ { label: "Mitglied", value: 1 }, { label: "Manager", value: 2 }, ]; -const onTypeSelected = (e) => { +const onPermissionLevelSelected = (e) => { emit("update", props.member.id, { - type: e.target.value, - }) + permissionLevel: parseInt(e.target.value, 10), + }); }; const onDeleteClicked = (e) => { - emit("delete", props.member.id) + emit("delete", props.member.id); }; @@ -52,8 +52,8 @@ const onDeleteClicked = (e) => { - + diff --git a/src/components/MemberList/MemberListNewRole.vue b/src/components/MemberList/MemberListNewRole.vue new file mode 100644 index 0000000..fb4bda6 --- /dev/null +++ b/src/components/MemberList/MemberListNewRole.vue @@ -0,0 +1,144 @@ + + + + + diff --git a/src/components/MemberList/ResourceMembersList.vue b/src/components/MemberList/ResourceMembersList.vue new file mode 100644 index 0000000..2e7689d --- /dev/null +++ b/src/components/MemberList/ResourceMembersList.vue @@ -0,0 +1,155 @@ + + + + + diff --git a/src/components/MemberList/index.js b/src/components/MemberList/index.js deleted file mode 100644 index a7bf749..0000000 --- a/src/components/MemberList/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from "./MemberList.vue" diff --git a/src/views/ResourceSettings.vue b/src/views/ResourceSettings.vue index 5936d32..03f0a0c 100644 --- a/src/views/ResourceSettings.vue +++ b/src/views/ResourceSettings.vue @@ -6,7 +6,7 @@ import { NcLoadingIcon, NcCheckboxRadioSwitch, NcButton, NcTextField } from '@ne import BackupRestore from "vue-material-design-icons/BackupRestore.vue"; import Delete from "vue-material-design-icons/Delete.vue"; -import MemberList from "../components/MemberList/index.js"; +import ResourceMembersList from "../components/MemberList/ResourceMembersList.vue"; import Permissions from "../components/Permissions/index.js"; import ConfirmDeleteDialog from "../components/ConfirmDeleteDialog.vue"; import ModalView from '../ModalView.vue'; @@ -31,7 +31,11 @@ const resourceNameValid = computed(() => { }); const saveName = async () => { - resource.value = await api.updateResource(resource.value.id, { name: currentResourceName.value }); + resource.value = await api.updateResource(resource.value.id, { name: currentResourceName.value }, "model+members"); +}; + +const saveInheritManagers = async (inheritManagers) => { + resource.value = await api.updateResource(resource.value.id, { inheritManagers }, "model+members"); }; watch(() => props.resourceId, async (newResourceId) => { @@ -43,28 +47,54 @@ watch(() => props.resourceId, async (newResourceId) => { const saveActive = async (active) => { resourceActiveLoading.value = true; - resource.value = await api.updateResource(resource.value.id, { active }); + resource.value = await api.updateResource(resource.value.id, { active }, "model+members"); resourceActiveLoading.value = false; }; const savePermission = async ({ field, value }) => { resource.value = await api.updateResource(resource.value.id, { [field]: value, - }); + }, "model+members"); }; const switchToSnapshotRestoreView = () => { }; +const addMember = async (principalType, principalId) => { + resource.value.members.push(await api.createResourceMember(resource.value.id, { + permissionLevel: api.ResourceMemberPermissionLevels.MEMBER, + principalType, + principalId, + })); +}; + +const updateMember = async (memberId, updateResourceMemberDto) => { + const member = await api.updateResourceMember(memberId, updateResourceMemberDto); + resource.value.members = resource.value.members.map((m) => m.id === member.id ? member : m); +}; + +const deleteMember = async (memberId) => { + await api.deleteResourceMember(memberId); + resource.value.members = resource.value.members.filter((m) => m.id !== memberId); +}; + const snapshotIntegrationActive = loadState('organization_folders', 'snapshot_integration_active', false); +const organizationProviders = ref([]); + +api.getOrganizationProviders().then((providers) => { + organizationProviders.value = providers; +}); + +const validResourceMemberPrincipalTypes = api.PrincipalTypes; +