Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class DocumentHeader extends React.PureComponent<Props, any> {
>
<Alert severity="info">
<AlertTitle>{$t('who_can_view_this_document')}</AlertTitle>
{getDocumentShareSummary(item.access, item.attachmentRelations)}
{getDocumentShareSummary(item.displayAccess, item.attachmentRelations)}
</Alert>
</Popover>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ const DocumentShare: React.FC<Props> = ({

const contactRelated = isSingleContactAttachment(documentSource.attachmentRelations);

const SummaryLabel = useMemo(() => getDocumentShareSummary(documentSource.access, documentSource.attachmentRelations),
[documentSource.access, documentSource.attachmentRelations]);
const SummaryLabel = useMemo(() => getDocumentShareSummary(documentSource.displayAccess, documentSource.attachmentRelations),
[documentSource.displayAccess, documentSource.attachmentRelations]);

const linkOrPublic = ["Link", "Public"].includes(documentSource.access);

Expand Down
13 changes: 12 additions & 1 deletion client-html/src/js/common/utils/documents/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ export const getDocumentShareSummary = (
: ', all tutors in skillsOnCourse portal';
break;
}
case 'Students only': {
if (isSingleContactAttachment(attachmentRelations)) {
label += ', ' + attachmentRelations.map(r =>
r.relatedContacts.map(c => c.name));
break;
}
if (attachmentRelations.length) {
label += ', some students in skillsOnCourse portal';
}
break;
}
case 'Tutors and enrolled students': {
if (isSingleContactAttachment(attachmentRelations)) {
label += ', ' + attachmentRelations.map(r =>
Expand Down Expand Up @@ -127,4 +138,4 @@ export const groupAttachmentsByEntity = (attachmentRelations: DocumentAttachment
export const getLatestDocumentItem = (data: DocumentVersion[]) => {
if (data && data.length === 1) return data[0];
return data.find(elem => elem.current);
};
};
23 changes: 14 additions & 9 deletions client-html/src/js/containers/entities/documents/Documents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,35 +68,40 @@ interface DocumentProps {
setListFullScreenEditView?: BooleanArgFunction;
}

const isRemoved = (value: string) => "isRemoved is " + value;
const isRemoved = (value: boolean) => "isRemoved is " + value;

const filterGroups: FilterGroup[] = [
{
title: "CORE FILTER",
filters: [
{
name: "Website",
expression: "webVisibility is PUBLIC and " + isRemoved("false"),
expression: `displayWebVisibility is PUBLIC and ${isRemoved(false)}`,
active: true
},
{
name: "Private",
expression: "webVisibility is PRIVATE and " + isRemoved("false"),
expression: `displayWebVisibility is PRIVATE and ${isRemoved(false)}`,
active: true
},
{
name: "Tutors and enrolled students",
expression: "webVisibility is STUDENTS and " + isRemoved("false"),
expression: `displayWebVisibility is TUTORS_AND_ENROLLED_STUDENTS and ${isRemoved(false)}`,
active: true
},
{
name: "Tutors",
expression: "webVisibility is TUTORS and " + isRemoved("false"),
name: "Tutors only",
expression: `displayWebVisibility is TUTORS_ONLY and ${isRemoved(false)}`,
active: true
},
{
name: "Students only",
expression: `displayWebVisibility is STUDENTS_ONLY and ${isRemoved(false)}`,
active: true
},
{
name: "Linkable",
expression: "(webVisibility is PUBLIC or webVisibility is LINK) and " + isRemoved("false"),
expression: `(webVisibility is PUBLIC or webVisibility is LINK) and ${isRemoved(false)}`,
active: true
},
{
Expand All @@ -108,7 +113,7 @@ const filterGroups: FilterGroup[] = [
<Delete style={{ fontSize: "18px" }} color="disabled" />
</span>
),
expression: isRemoved("true"),
expression: isRemoved(true),
active: false
}
]
Expand Down Expand Up @@ -283,4 +288,4 @@ const mapDispatchToProps = (dispatch: Dispatch<any>) => ({
clearEditingDocument: () => dispatch(clearEditingDocument())
});

export default connect<any, any, any>(mapStateToProps, mapDispatchToProps)(withStyles(Documents, styles));
export default connect<any, any, any>(mapStateToProps, mapDispatchToProps)(withStyles(Documents, styles));
2 changes: 2 additions & 0 deletions server-api/src/main/resources/def/entity/Document.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ properties:
type: string
access:
$ref: '../enum/DocumentVisibility.yaml'
displayAccess:
$ref: '../enum/DocumentVisibility.yaml'
shared:
type: boolean
removed:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ enum:
- Public
- Tutors and enrolled students
- Tutors only
- Students only
- Link
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class DocumentApiService extends TaggableApiService<DocumentDTO, Document, Docum

document.description = dbDocument.description
document.access = DocumentVisibilityDTO.values()[0].fromDbType(dbDocument.webVisibility)
document.displayAccess = dbDocument.displayWebVisibility
document.shared = dbDocument.isShared
document.removed = dbDocument.isRemoved
document.createdOn = LocalDateUtils.dateToTimeValue(dbDocument.createdOn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class DocumentFunctions {

document.description = dbDocument.description
document.access = DocumentVisibilityDTO.values()[0].fromDbType(dbDocument.webVisibility)
document.displayAccess = dbDocument.displayWebVisibility
document.shared = dbDocument.isShared
document.removed = dbDocument.isRemoved
document.createdOn = LocalDateUtils.dateToTimeValue(dbDocument.createdOn)
Expand All @@ -87,6 +88,7 @@ class DocumentFunctions {
document.description = dbDocument.description
document.added = LocalDateUtils.dateToTimeValue(dbDocument.added)
document.access = DocumentVisibilityDTO.values()[0].fromDbType(dbDocument.webVisibility)
document.displayAccess = dbDocument.displayWebVisibility
document.shared = dbDocument.isShared
document.removed = dbDocument.isRemoved
AmazonS3Service s3Service = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ import javax.annotation.Nonnull
@QueueableEntity
abstract class AttachmentRelation extends _AttachmentRelation implements Queueable, ContactActivityTrait {


public static final List<String> TUTOR_RELATED_ENTITIES = List.of(
Assessment.class.simpleName,
CourseClass.class.simpleName,
Course.class.simpleName
)

/**
* @return attached record
Expand Down
26 changes: 24 additions & 2 deletions server/src/main/groovy/ish/oncourse/server/cayenne/Document.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import ish.common.types.AttachmentInfoVisibility
import ish.common.types.NodeType
import ish.oncourse.API
import ish.oncourse.cayenne.QueueableEntity
import ish.oncourse.server.api.v1.model.DocumentVisibilityDTO
import ish.oncourse.server.cayenne.glue._Document
import ish.oncourse.server.document.DocumentService
import ish.oncourse.server.license.LicenseService
Expand All @@ -36,6 +37,7 @@ class Document extends _Document implements DocumentTrait, Queueable {
public static final String LINK_PROPERTY = "link"
public static final String ACTIVE_PROPERTY = "active"
public static final String CURRENT_VERSION_PROPERTY = "currentVersion"
public static final String DISPLAY_WEB_VISIBILITY_PROPERTY = "displayWebVisibility"

@Inject
private DocumentService documentService
Expand Down Expand Up @@ -214,7 +216,27 @@ class Document extends _Document implements DocumentTrait, Queueable {
String collegeKey = licenseService.getCollege_key()
return collegeKey != null ? "https://${collegeKey}.cloud.oncourse.cc/document/${id}" : ""
}
}



/**
* Returns the display value of webVisibility, considering document attachments.
*
* @return this document's display visibility
*/
@API
DocumentVisibilityDTO getDisplayWebVisibility() {
boolean hasCourseAttachment = attachmentRelations.stream()
.map { it -> it.entityIdentifier }
.anyMatch { it -> AttachmentRelation.TUTOR_RELATED_ENTITIES.contains(it) }

def visibility = DocumentVisibilityDTO.values()[0].fromDbType(webVisibility)
if (!hasCourseAttachment) {
if (visibility == DocumentVisibilityDTO.TUTORS_AND_ENROLLED_STUDENTS) {
return DocumentVisibilityDTO.STUDENTS_ONLY
} else if (visibility == DocumentVisibilityDTO.TUTORS_ONLY) {
return DocumentVisibilityDTO.PRIVATE
}
}
return visibility
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class DefaultUserPreference {
new ColumnDTO(title: 'Document name', attribute: Document.NAME.name, sortable: true, width: W200, visible: true),
new ColumnDTO(title: 'Date added', attribute: Document.ADDED.name, sortable: true, width: W200, visible: true, type: ColumnTypeDTO.DATE),
new ColumnDTO(title: 'Size', attribute: Document.CURRENT_VERSION_PROPERTY + "." + DocumentVersion.BYTE_SIZE.name, sortable: false, width: W200, visible: true),
new ColumnDTO(title: 'Security level', attribute: Document.WEB_VISIBILITY.name, sortable: true, width: W100, visible: true),
new ColumnDTO(title: 'Security level', attribute: Document.DISPLAY_WEB_VISIBILITY_PROPERTY, sortable: false, width: W100, visible: true, prefetches: [Document.ATTACHMENT_RELATIONS.path().toString()]),
new ColumnDTO(title: 'File name', attribute: Document.CURRENT_VERSION_PROPERTY + "." + DocumentVersion.FILE_NAME.name, sortable: false, width: W100, visible: true),
new ColumnDTO(title: 'Type', attribute: Document.CURRENT_VERSION_PROPERTY + "." + DocumentVersion.MIME_TYPE.name, sortable: false, width: W100, visible: true),
new ColumnDTO(title: 'Active', attribute: Document.ACTIVE_PROPERTY, sortable: false, width: W100, visible: false, system: true, type: ColumnTypeDTO.BOOLEAN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class EntityFactory {
CourseClassEnrolmentMin.class,
CourseClassSessionsCount.class,
CourseClassIsDistantLearningCourse.class,
DocumentDisplayWebVisibility.class,
EnrolmentIsClassCompleted.class,
SessionTutor.class,
PaymentInBanking.class,
Expand Down Expand Up @@ -196,4 +197,3 @@ private boolean entityIsTaggable(String entityName){
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright ish group pty ltd 2025.
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License version 3 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*/

package ish.oncourse.aql.model.attribute;

import ish.oncourse.aql.model.EntityFactory;
import ish.oncourse.aql.model.SyntheticAttributeDescriptor;
import ish.oncourse.server.cayenne.Document;
import org.apache.cayenne.Persistent;
import org.apache.cayenne.exp.parser.SimpleNode;

import java.util.Optional;

public class DocumentDisplayWebVisibility implements SyntheticAttributeDescriptor {

public DocumentDisplayWebVisibility(EntityFactory entityFactory) {
}

@Override
public Class<? extends Persistent> getEntityType() {
return Document.class;
}

@Override
public String getAttributeName() {
return Document.DISPLAY_WEB_VISIBILITY_PROPERTY;
}

@Override
public SimpleNode spawnNode() {
return new SyntheticDocumentDisplayWebVisibilityNode();
}

@Override
public Optional<Class<?>> getAttributeType() {
return Optional.of(String.class);
}
}
Loading
Loading