Add confirmation to request resolution. Fix date change notification sometimes being sent twice since reordering of event dates. Make only switch clickable in editable-event component, as per Kate's feedback.

This commit is contained in:
Georgi Prodanov 2017-03-17 17:04:16 +02:00
Родитель 802da9fff8
Коммит 5370f4dc73
6 изменённых файлов: 23 добавлений и 20 удалений

Просмотреть файл

@ -42,10 +42,6 @@ export class EditableEventComponent implements OnInit {
this._handleEventDatesIfPresent(this.event);
}
toggleOpenForRegistration() {
this.event.OpenForRegistration = !this.event.OpenForRegistration;
}
onAddDateOption(date: Date) {
let clone = new Date(date.getTime());
this._addDateOptionToEvent(clone);

Просмотреть файл

@ -52,7 +52,7 @@
<user-display [users]="currentUser" [showNames]="true"></user-display>
</StackLayout>
<StackLayout *ngIf="!event.RegistrationCompleted" class="input-field switch-field" (tap)="toggleOpenForRegistration()">
<StackLayout *ngIf="!event.RegistrationCompleted" class="input-field switch-field">
<Label class="label" text="Visibility"></Label>
<GridLayout columns="*, 65" class="switch-wrp border-bottom">
<Label col="0" text="Visible to group members"></Label>

Просмотреть файл

@ -76,7 +76,9 @@ export class GroupJoinRequestsComponent extends AndroidBackOverrider implements
return;
}
this._lockedRequests[request.Id] = true;
this._groupsService.resolveJoinRequest(request.Id, approve)
let text = this._getApprovalConfirmationText(request, approve);
this._alertsService.askConfirmation(text)
.then(() => this._groupsService.resolveJoinRequest(request.Id, approve))
.then((resp) => {
request.Approved = approve;
request.Resolved = true;
@ -99,6 +101,12 @@ export class GroupJoinRequestsComponent extends AndroidBackOverrider implements
return text;
}
private _getApprovalConfirmationText(request: GroupJoinRequest, approve: boolean) {
let approval = (approve ? 'Approve' : 'Deny');
let userName = request.Applicant.DisplayName || request.Applicant.Username;
return approval + ` ${userName}'s request to join?`;
}
private _loadRequests() {
if (this._lockLoadMore) {
return;

Просмотреть файл

@ -157,7 +157,6 @@ export class GroupsService {
.then(r => r.result);
}
getRequests(groupId: string, page = 0, pageSize = 10, expandExp?: any) {
expandExp = expandExp || {
ApplicantId: {
@ -171,7 +170,7 @@ export class GroupsService {
.skip(page * pageSize)
.take(pageSize)
.orderDesc('CreatedAt')
.expand(expandExp)
.expand(expandExp);
return this._groupJoinRequests.get(query).then(r => r.result);
}

Просмотреть файл

@ -1,7 +1,9 @@
import { ItemModel } from './item.model';
import { User } from './';
export class GroupJoinRequest extends ItemModel {
ApplicantId: string;
Applicant?: User; // when expanded
GroupId: string;
Approved: boolean;
Resolved: boolean;

Просмотреть файл

@ -118,20 +118,18 @@ Everlive.Events.afterUpdate(function(request, response, context, done) {
sendNotificationsToUsers(eventId, event.GroupId, 'EventDatesUpdated');
} else {
var byDate = {};
oldDates.forEach(function(date) {
byDate[date] = true;
var notified = false;
newDates = newDates.map(function(d) {
return d.toISOString();
});
for (var i = 0; i < newDates.length; i++) {
var key = newDates[i].toISOString();
if (byDate[key]) {
delete byDate[key];
} else {
sendNotificationsToUsers(eventId, event.GroupId, 'EventDatesUpdated');
break;
}
}
if (_.size(byDate)) {
var datesRemoved = _.difference(oldDates, newDates);
if (datesRemoved.length) {
sendNotificationsToUsers(eventId, event.GroupId, 'EventDatesUpdated');
} else {
var datesAdded = _.difference(newDates, oldDates);
if (datesAdded.length) {
sendNotificationsToUsers(eventId, event.GroupId, 'EventDatesUpdated');
}
}
}
}