Skip to content
Merged
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
23 changes: 22 additions & 1 deletion app/components/events/view/overview/manage-roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default class ManageRoles extends Component {
}

@action
deleteUserRole(invite) {
deleteUserRoleInvite(invite) {
this.set('isLoading', true);
invite.destroyRecord()
.then(() => {
Expand All @@ -86,6 +86,27 @@ export default class ManageRoles extends Component {
});
}

@action
deleteUserRole(eventRole) {
this.set('isLoading', true);
eventRole.destroyRecord()
.then(() => {
this.notify.success(this.l10n.t('Role deleted successfully'), {
id: 'del_role_succ'
});
this.data.usersEventsRoles.removeObject(eventRole);
})
.catch(e => {
console.error('Error while deleting role', e);
this.notify.error(this.l10n.t('Oops something went wrong. Please try again'), {
id: 'err_man_role'
});
})
.finally(() => {
this.set('isLoading', false);
});
}

@action
filter(type) {
this.set('roleType', type);
Expand Down
1 change: 1 addition & 0 deletions app/models/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export default class Event extends ModelBase.extend(CustomPrimaryKeyMixin, {
trackOrganizers : hasMany('user', { inverse: null }),
registrars : hasMany('user', { inverse: null }),
moderators : hasMany('user', { inverse: null }),
roles : hasMany('users-events-role'),

/**
* The discount code applied to this event [Form(1) discount code]
Expand Down
8 changes: 8 additions & 0 deletions app/models/users-events-role.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import ModelBase from 'open-event-frontend/models/base';
import { belongsTo } from 'ember-data/relationships';

export default ModelBase.extend({
event : belongsTo('event'),
role : belongsTo('role'),
user : belongsTo('user')
});
10 changes: 7 additions & 3 deletions app/routes/events/view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export default class extends Route.extend(EmberTableRouteMixin) {
const roleInvitesPromise = eventDetails.query('roleInvites', {
include: 'role'
});
const usersEventsRolesPromise = eventDetails.query('roles', {
include: 'user,role'
});
const sessionTypesPromise = eventDetails.query('sessionTypes', {});
const tracksPromise = eventDetails.query('tracks', {});
const microlocationsPromise = eventDetails.query('microlocations', {});
Expand All @@ -29,8 +32,8 @@ export default class extends Route.extend(EmberTableRouteMixin) {
const ticketsPromise = eventDetails.query('tickets', {});

const [sponsors, roleInvites, sessionTypes, tracks, microlocations, speakersCall, socialLinks,
statistics, orderStat, tickets] = (await allSettled([sponsorsPromise, roleInvitesPromise, sessionTypesPromise, tracksPromise, microlocationsPromise, speakersCallPromise, socialLinksPromise,
statisticsPromise, orderStatPromise, ticketsPromise])).map(result => result.value);
statistics, orderStat, tickets, usersEventsRoles] = (await allSettled([sponsorsPromise, roleInvitesPromise, sessionTypesPromise, tracksPromise, microlocationsPromise, speakersCallPromise, socialLinksPromise,
statisticsPromise, orderStatPromise, ticketsPromise, usersEventsRolesPromise])).map(result => result.value);


return {
Expand All @@ -44,7 +47,8 @@ export default class extends Route.extend(EmberTableRouteMixin) {
socialLinks,
statistics,
orderStat,
tickets
tickets,
usersEventsRoles
};
}
}
3 changes: 3 additions & 0 deletions app/routes/events/view/team/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export default class EventsViewTeamIndex extends Route.extend({
roleInvites: event.query('roleInvites', {
include: 'role'
}),
usersEventsRoles: event.query('roles', {
include: 'user,role'
}),
roles: this.store.findAll('role')
});
}
Expand Down
90 changes: 50 additions & 40 deletions app/templates/components/events/view/overview/manage-roles.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,62 @@
<tr>
<th>{{t 'User (Email)'}}</th>
<th>{{t 'Role'}}</th>
{{#if (and @editable (eq this.roleType 'pending'))}}
{{#if @editable}}
<th>{{t 'Options'}}</th>
{{/if}}
</tr>
</thead>
<tbody>
{{#each this.roleInvites as |roleInvite|}}
<tr>
<td>{{roleInvite.email}}</td>
<td>{{t-var roleInvite.role.titleName}}</td>
{{#if (and @editable (eq this.roleType 'pending'))}}
<td>
<div class="ui horizontal compact basic buttons">
{{#if (eq this.roleType 'accepted')}}
<UiPopup
@content={{t "Delete"}}
@class="ui icon button"
@click={{action (confirm (t "Are you sure you would like to delete this role?") (action "deleteUserRole" roleInvite))}}>
<i class="trash icon"></i>
</UiPopup>
{{else}}
<UiPopup
@content={{t "Delete"}}
@class="ui icon button"
@click={{action (confirm (t "Are you sure you would like to cancel this invite?") (action "deleteUserRole" roleInvite))}}>
<i class="trash icon"></i>
</UiPopup>
{{/if}}
{{#if (eq this.roleType 'pending')}}
<UiPopup
@content={{t "Resend invite"}}
@click={{action "resendInvite" roleInvite}}
@class="ui icon button"
@position="top center">
<i class="mail outline icon"></i>
</UiPopup>
{{/if}}
</div>
</td>
{{/if}}
</tr>
{{#if (eq this.roleType 'pending')}}
{{#each this.roleInvites as |roleInvite|}}
<tr>
<td>{{roleInvite.email}}</td>
<td>{{t-var roleInvite.role.titleName}}</td>
{{#if (and @editable (eq this.roleType 'pending'))}}
<td>
<div class="ui horizontal compact basic buttons">
<UiPopup
@content={{t "Delete"}}
@class="ui icon button"
@click={{action (confirm (t "Are you sure you would like to cancel this invite?") (action "deleteUserRole" roleInvite))}}>
<i class="trash icon"></i>
</UiPopup>
<UiPopup
@content={{t "Resend invite"}}
@click={{action "resendInvite" roleInvite}}
@class="ui icon button"
@position="top center">
<i class="mail outline icon"></i>
</UiPopup>
</div>
</td>
{{/if}}
</tr>
{{else}}
<div class="ui basic segment">
{{t 'No records to show'}}
</div>
{{/each}}
{{else}}
<div class="ui basic segment">
{{t 'No records to show'}}
</div>
{{/each}}
{{#each this.data.usersEventsRoles as |eventRole|}}
<tr>
<td>{{eventRole.user.email}}</td>
<td>{{eventRole.role.titleName}}</td>
{{#if (and @editable (not-eq eventRole.role.name 'owner'))}}
<td>
<div class="ui horizontal compact basic buttons">
<UiPopup
@content={{t "Delete"}}
@class="ui icon button"
@click={{action (confirm (t "Are you sure you would like to delete this role?") (action "deleteUserRole" eventRole))}}>
<i class="trash icon"></i>
</UiPopup>
</div>
</td>
{{/if}}
</tr>
{{/each}}
{{/if}}
</tbody>
</table>
</div>
Expand Down