Skip to content

Commit

Permalink
#613 set user availability when creating an event (#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
rezk2ll authored Nov 15, 2021
1 parent 51d6635 commit 4a78fdc
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/esn.calendar.libs/app/app.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,19 @@
label: 'Private'
}
]
},
availability: {
default: 'OPAQUE',
values: [
{
value: 'OPAQUE',
label: 'Busy'
},
{
value: 'TRANSPARENT',
label: 'Free'
}
]
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ function CalEventFormController(
$scope.editedEvent.class = CAL_EVENT_FORM.class.default;
}

if (!$scope.editedEvent.availability) {
$scope.editedEvent.availability = CAL_EVENT_FORM.availability.default;
}

$scope.displayParticipationButton = displayParticipationButton();
$scope.displayCalMailToAttendeesButton = displayCalMailToAttendeesButton;
$scope.$watch('selectedCalendar.uniqueId', setExcludeCurrentUser);
Expand Down
13 changes: 11 additions & 2 deletions src/esn.calendar.libs/app/components/event/form/event-form.pug
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,24 @@ form.event-form(role="form", name="form", aria-hidden="true", ng-class="{ 'reado
event-recurrence-edition(ng-click="changeBackdropZIndex()", event="editedEvent", can-modify-event-recurrence='canModifyEventRecurrence')
.col-xs-12
cal-event-alarm-edition(ng-click="changeBackdropZIndex()", event="editedEvent", can-modify-event= "canModifyEvent")
.col-xs-12
div(ng-class="isOrganizer ? 'col-xs-6' : 'col-xs-12'")
.form-group
.input-group
span.input-group-addon
i.mdi.mdi-lock
.fg-line
md-input-container(ng-click="changeBackdropZIndex()")
md-select(ng-disabled="!canModifyEvent", ng-model='editedEvent.class', md-container-class="cal-select-dropdown", aria-label="visibility")
md-option(ng-value='class.value', ng-repeat="class in CAL_EVENT_FORM.class.values") {{class.label | translate}}
md-option(ng-value='class.value', ng-repeat="class in CAL_EVENT_FORM.class.values") {{class.label | translate}}
div(ng-class="isOrganizer ? 'col-xs-6' : 'col-xs-12'", ng-if="isOrganizer")
.form-group
.input-group
span.input-group-addon
i.mdi.mdi-eye
.fg-line
md-input-container(ng-click="changeBackdropZIndex()")
md-select(ng-disabled="!canModifyEvent", ng-model='editedEvent.availability', md-container-class="cal-select-dropdown", aria-label="availability")
md-option(ng-value='availability.value', ng-repeat="availability in CAL_EVENT_FORM.availability.values") {{ availability.label | translate }}

.modal-footer.flex
.flex-vertical-centered.flex-start
Expand Down
8 changes: 8 additions & 0 deletions src/esn.calendar.libs/app/services/shells/calendar-shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,14 @@ require('./valarm-shell.js');
vevent.updatePropertyWithValue('class', value);
});
this.ensureAlarmCoherence();
},

get availability() {
return this.vevent.getFirstPropertyValue('transp');
},

set availability(value) {
this.vevent.updatePropertyWithValue('transp', value);
}
};

Expand Down
19 changes: 19 additions & 0 deletions src/esn.calendar.libs/app/services/shells/calendar-shell.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2234,4 +2234,23 @@ describe('CalendarShell factory', function() {
expect((new CalendarShell(newVCalendar)).dtstamp).to.be.null;
});
});

describe('the availability setter', () => {
it('should set the event availability', () => {
const vcalendar = ICAL.Component.fromString(__FIXTURES__['src/linagora.esn.calendar/app/fixtures/calendar/event.ics']);
const calendarShell = new CalendarShell(vcalendar);

calendarShell.availability = 'TRANSPARENT';
expect(calendarShell.vevent.getFirstPropertyValue('transp')).to.equal('TRANSPARENT');
});
});

describe('the availability getter', () => {
it('should return the event availability', () => {
const vcalendar = ICAL.Component.fromString(__FIXTURES__['src/linagora.esn.calendar/app/fixtures/calendar/event.ics']);
const calendarShell = new CalendarShell(vcalendar);

expect(calendarShell.availability).to.equal('OPAQUE');
});
});
});

0 comments on commit 4a78fdc

Please sign in to comment.