aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2020-09-19 17:59:00 -0400
committerbobzel <zzzman@gmail.com>2020-09-19 17:59:00 -0400
commitd4f3dd01976739be98d25d77708856230eb35d3e (patch)
tree298e29a4b466da9f05da49fd6f690abbb24d9c1c
parent743cc8b98549dddd4fe5caaa9740caf95a57d56e (diff)
changed Add-Only so that if you have Admin rights to a document you can remove it from a read-only or add-only collection
-rw-r--r--src/client/views/DocumentDecorations.tsx3
-rw-r--r--src/client/views/collections/CollectionView.tsx11
2 files changed, 10 insertions, 4 deletions
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index 9a49093b4..96eba1869 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -580,7 +580,8 @@ export class DocumentDecorations extends React.Component<{}, { value: string }>
}
const canDelete = SelectionManager.SelectedDocuments().some(docView => {
const collectionAcl = docView.props.ContainingCollectionView ? GetEffectiveAcl(docView.props.ContainingCollectionDoc?.[DataSym]) : AclEdit;
- return !docView.props.Document._stayInCollection && (collectionAcl === AclAdmin || collectionAcl === AclEdit);
+ const docAcl = GetEffectiveAcl(docView.props.Document);
+ return !docView.props.Document._stayInCollection && (collectionAcl === AclAdmin || collectionAcl === AclEdit || docAcl === AclAdmin);
});
const canOpen = SelectionManager.SelectedDocuments().some(docView => !docView.props.Document._stayInCollection);
const closeIcon = !canDelete ? (null) : (
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 312bc045f..c9496d374 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -185,7 +185,8 @@ export class CollectionView extends Touchable<FieldViewProps & CollectionViewCus
@action.bound
removeDocument = (doc: any): boolean => {
const effectiveAcl = GetEffectiveAcl(this.props.Document[DataSym]);
- if (effectiveAcl === AclEdit || effectiveAcl === AclAdmin) {
+ const docAcl = GetEffectiveAcl(doc);
+ if (effectiveAcl === AclEdit || effectiveAcl === AclAdmin || docAcl === AclAdmin) {
const docs = doc instanceof Doc ? [doc] : doc as Doc[];
const targetDataDoc = this.props.Document[DataSym];
const value = DocListCast(targetDataDoc[this.props.fieldKey]);
@@ -193,8 +194,12 @@ export class CollectionView extends Touchable<FieldViewProps & CollectionViewCus
if (toRemove.length !== 0) {
const recent = Cast(Doc.UserDoc().myRecentlyClosedDocs, Doc) as Doc;
toRemove.forEach(doc => {
- Doc.RemoveDocFromList(targetDataDoc, this.props.fieldKey, doc);
- recent && Doc.AddDocToList(recent, "data", doc, undefined, true, true);
+ const ind = (targetDataDoc[this.props.fieldKey] as List<Doc>).indexOf(doc);
+ (targetDataDoc[this.props.fieldKey] as List<Doc>).splice(ind, 0);
+ if (ind !== -1) {
+ Doc.RemoveDocFromList(targetDataDoc, this.props.fieldKey, doc);
+ recent && Doc.AddDocToList(recent, "data", doc, undefined, true, true);
+ }
});
return true;
}