forked from potsda.mn/mobilizon
Fix moving resources
Closes #838 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
04fff8485e
commit
a7a0c58ae3
|
@ -59,7 +59,7 @@
|
||||||
{{ $t("No resources in this folder") }}
|
{{ $t("No resources in this folder") }}
|
||||||
</p>
|
</p>
|
||||||
<b-pagination
|
<b-pagination
|
||||||
v-if="resource.children.total > RESOURCES_PER_PAGE"
|
v-if="resource.children && resource.children.total > RESOURCES_PER_PAGE"
|
||||||
:total="resource.children.total"
|
:total="resource.children.total"
|
||||||
v-model="page"
|
v-model="page"
|
||||||
size="is-small"
|
size="is-small"
|
||||||
|
|
|
@ -622,8 +622,7 @@ export default class Resources extends Mixins(ResourceMixin) {
|
||||||
}
|
}
|
||||||
const updatedResource: IResource = data.updateResource;
|
const updatedResource: IResource = data.updateResource;
|
||||||
|
|
||||||
// eslint-disable-next-line vue/max-len
|
const updatedElementList =
|
||||||
oldParentCachedResource.children.elements =
|
|
||||||
oldParentCachedResource.children.elements.filter(
|
oldParentCachedResource.children.elements.filter(
|
||||||
(cachedResource) => cachedResource.id !== updatedResource.id
|
(cachedResource) => cachedResource.id !== updatedResource.id
|
||||||
);
|
);
|
||||||
|
@ -634,7 +633,15 @@ export default class Resources extends Mixins(ResourceMixin) {
|
||||||
path: parentPath,
|
path: parentPath,
|
||||||
username: this.resource.actor.preferredUsername,
|
username: this.resource.actor.preferredUsername,
|
||||||
},
|
},
|
||||||
data: { oldParentCachedResource },
|
data: {
|
||||||
|
resource: {
|
||||||
|
...oldParentCachedResource,
|
||||||
|
children: {
|
||||||
|
...oldParentCachedResource.children,
|
||||||
|
elements: [...updatedElementList],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
console.log("Finished removing ressource from old parent");
|
console.log("Finished removing ressource from old parent");
|
||||||
|
|
||||||
|
@ -659,15 +666,24 @@ export default class Resources extends Mixins(ResourceMixin) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
newParentCachedResource.children.elements.push(resource);
|
|
||||||
|
|
||||||
store.writeQuery({
|
store.writeQuery({
|
||||||
query: GET_RESOURCE,
|
query: GET_RESOURCE,
|
||||||
variables: {
|
variables: {
|
||||||
path: updatedResource.parent.path,
|
path: updatedResource.parent.path,
|
||||||
username: this.resource.actor.preferredUsername,
|
username: this.resource.actor.preferredUsername,
|
||||||
},
|
},
|
||||||
data: { newParentCachedResource },
|
data: {
|
||||||
|
resource: {
|
||||||
|
...newParentCachedResource,
|
||||||
|
children: {
|
||||||
|
...newParentCachedResource.children,
|
||||||
|
elements: [
|
||||||
|
...newParentCachedResource.children.elements,
|
||||||
|
resource,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
console.log("Finished adding resource to new parent");
|
console.log("Finished adding resource to new parent");
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue