Skip to content

Commit

Permalink
feat(calendar(web)): allow to change the classification of an event
Browse files Browse the repository at this point in the history
  • Loading branch information
cgx committed Nov 4, 2020
1 parent 3796009 commit 4a83733
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 8 deletions.
29 changes: 28 additions & 1 deletion UI/Scheduler/UIxAppointmentEditor.m
Original file line number Diff line number Diff line change
Expand Up @@ -285,27 +285,35 @@ - (NSException *) _adjustRecurrentRules
* @apiParam {String} alarm.relation Either START or END
* @apiParam {Boolean} [alarm.attendees] Alert attendees by email if 1 and action is email
* @apiParam {Boolean} [alarm.organizer] Alert organizer by email if 1 and action is email
* @apiParam {String} [classification] Either public, confidential or private
*/
- (id <WOActionResults>) rsvpAction
{
static NSArray *validClassifications = nil;
iCalPerson *delegatedAttendee;
NSDictionary *params, *jsonResponse;
WOResponse *response;
WORequest *request;
iCalAlarm *anAlarm;
iCalEvent *event;
NSException *ex;
NSString *status;
id alarm;
id alarm, classification;

int replyList;

if (!validClassifications)
validClassifications = [[NSArray alloc] initWithObjects: @"PUBLIC", @"CONFIDENTIAL", @"PRIVATE", nil];

request = [context request];
params = [[request contentAsString] objectFromJSONString];
event = [self event];

delegatedAttendee = nil;
anAlarm = nil;
status = nil;

// Set invitation reply
replyList = [[params objectForKey: @"reply"] intValue];

switch (replyList)
Expand Down Expand Up @@ -368,6 +376,25 @@ - (NSException *) _adjustRecurrentRules
break;
}

// Update classification
classification = [params objectForKey: @"classification"];
if (classification &&
[classification isKindOfClass: [NSString class]] &&
[validClassifications containsObject: [classification uppercaseString]] &&
![[classification uppercaseString] isEqualToString: [event accessClass]])
{
[event setAccessClass: [classification uppercaseString]];
ex = [[self clientObject] saveComponent: event force: NO];
if (ex)
{
jsonResponse = [NSDictionary dictionaryWithObjectsAndKeys:
[ex reason], @"message",
nil];
return [self responseWithStatus: [ex httpStatus]
andString: [jsonResponse jsonRepresentation]];
}
}

// Set an alarm for the user
alarm = [params objectForKey: @"alarm"];
if ([alarm isKindOfClass: [NSDictionary class]])
Expand Down
2 changes: 1 addition & 1 deletion UI/Templates/SchedulerUI/UIxAppointmentEditorTemplate.wox
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<md-dialog flex="60" flex-sm="80" flex-xs="100">
<form name="eventForm" class="md-inline-form" ng-submit="editor.save(eventForm)">
<md-toolbar>
<div class="md-toolbar-tools">
<div class="md-toolbar-tools sg-no-transition">
<md-icon class="material-icons sg-icon-toolbar-bg">event</md-icon>
<!-- summary -->
<md-icon ng-if="editor.component.classification == 'confidential'">visibility_off</md-icon>
Expand Down
22 changes: 19 additions & 3 deletions UI/Templates/SchedulerUI/UIxAppointmentViewTemplate.wox
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<md-toolbar>
<div class="md-toolbar-tools">
<md-icon class="material-icons sg-icon-toolbar-bg">event</md-icon>
<div class="sg-md-title md-flex">
<div class="sg-md-title md-flex sg-no-transition">
<!-- classification -->
<md-icon ng-if="::editor.component.classification == 'confidential'">visibility_off</md-icon>
<md-icon ng-if="::editor.component.classification == 'private'">vpn_key</md-icon>
<md-icon ng-if="editor.component.classification == 'confidential'">visibility_off</md-icon>
<md-icon ng-if="editor.component.classification == 'private'">vpn_key</md-icon>
<!-- priority -->
<md-icon ng-if="::editor.highPriority()">priority_high</md-icon>
<!-- summary -->
Expand Down Expand Up @@ -110,6 +110,22 @@
<div ng-bind="::editor.component.calendar"><!-- calendar --></div>
</div>
</md-list-item>
<!-- classification -->
<md-list-item>
<md-icon>visibility</md-icon>
<md-radio-group layout="row"
ng-model="editor.component.classification">
<md-radio-button class="sg-padded--right" value="public">
<var:string label:value="label_Public"/>
</md-radio-button>
<md-radio-button class="sg-padded--right" value="confidential">
<var:string label:value="label_Confidential"/>
</md-radio-button>
<md-radio-button value="private">
<var:string label:value="label_Private"/>
</md-radio-button>
</md-radio-group>
</md-list-item>
<!-- start/end dates -->
<md-list-item ng-class="{ 'md-2-line': editor.component.isAllDay, 'md-3-line': !editor.component.isAllDay }">
<md-icon>access_time</md-icon>
Expand Down
3 changes: 2 additions & 1 deletion UI/WebServerResources/js/Scheduler/Component.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,8 @@
data = {
reply: this.reply,
delegatedTo: this.delegatedTo,
alarm: this.$hasAlarm? this.alarm : {}
alarm: this.$hasAlarm? this.alarm : {},
classification: this.classification
};

return Component.$$resource.save(path, data, { action: 'rsvpAppointment' })
Expand Down
3 changes: 2 additions & 1 deletion UI/WebServerResources/js/Scheduler/ComponentController.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,11 @@
// Retrieve master event
component = Calendar.$get(this.component.pid).$getComponent(this.component.id);
component.$futureComponentData.then(function() {
// Propagate the participant status and alarm to the master event
// Propagate the participant status, classification and alarm to the master event
component.reply = vm.component.reply;
component.delegatedTo = vm.component.delegatedTo;
component.$hasAlarm = vm.component.$hasAlarm;
component.classification = vm.component.classification;
component.alarm = vm.component.alarm;
// Send reply to the server
vm.reply(component);
Expand Down
10 changes: 9 additions & 1 deletion UI/WebServerResources/scss/core/structure.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,12 @@ html * {
&:last-child {
margin-bottom: 0;
}
}
}

// Remove "leave" transition
// Convenient with a ng-switch statement or when using multiple ng-if statements that are mutually exclusive
.sg-no-transition {
.ng-leave {
display: none;
}
}

0 comments on commit 4a83733

Please sign in to comment.