Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
42 changes: 42 additions & 0 deletions app/components/modals/confirm-event-transfer-modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import FormMixin from 'open-event-frontend/mixins/form';
import ModalBase from 'open-event-frontend/components/modals/modal-base';

export default ModalBase.extend(FormMixin, {
actions: {
submit() {
this.onValid(() => {
this.sendAction('transferEvent');
});
},
close() {
if (!this.currentInvite.id) {
this.currentInvite.unloadRecord();
}
this.set('isOpen', false);
}
},

getValidationRules() {

return {
inline : true,
delay : false,
on : 'blur',
fields : {
newOwnerEmail: {
identifier : 'user_email',
rules : [
{
type : 'empty',
prompt : this.l10n.t('Please enter an email for new organizer')
},
{
type : 'email',
prompt : this.l10n.t('Please enter a valid email address for new organizer')
}
]
}
}
};
}
});
10 changes: 10 additions & 0 deletions app/components/modals/event-transfer-modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { computed } from '@ember/object';
import ModalBase from 'open-event-frontend/components/modals/modal-base';

export default ModalBase.extend({
isSmall : true,
confirmEventName : '',
isNameDifferent : computed('confirmEventName', 'eventName', function() {
return this.eventName ? this.confirmEventName.toLowerCase() !== this.eventName.toLowerCase() : true;
})
});
45 changes: 45 additions & 0 deletions app/controllers/events/view/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import Controller from '@ember/controller';

export default Controller.extend({

actions: {
openEventTransferModal(id, name) {
this.setProperties({
'isEventTransferModalOpen' : true,
'confirmEventName' : '',
'eventId' : id,
'eventName' : name
});
},
openConfirmEventTransferModal() {
const currentInvite = this.model.roleInvites.createRecord({});
let { roles } = this.model;
for (const role of roles ? roles.toArray() : []) {
if (role.name === 'owner') {
currentInvite.set('role', role);
}
}
this.setProperties({
'isEventTransferModalOpen' : false,
'isConfirmEventTransferModalOpen' : true,
'checked' : false,
currentInvite
});
},
async transferEvent() {
try {
this.set('isLoading', true);
this.currentInvite.set('roleName', 'owner');
await this.currentInvite.save();
this.setProperties({
'isConfirmEventTransferModalOpen' : false,
'checked' : false
});
this.notify.success(this.l10n.t('Owner Role Invite sent successfully.'));
} catch (error) {
this.notify.error(this.l10n.t(error.message));
}
this.set('isLoading', false);
}
}
});
1 change: 1 addition & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ router.map(function() {
this.route('attendee');
});
this.route('export');
this.route('settings');
this.route('sessions', function() {
this.route('list', { path: '/:session_status' });
this.route('create');
Expand Down
15 changes: 15 additions & 0 deletions app/routes/events/view/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Route from '@ember/routing/route';

export default Route.extend({
titleToken() {
return this.l10n.t('Settings');
},
async model() {
let eventDetails = this.modelFor('events.view');
return {
event : await eventDetails,
roleInvites : await eventDetails.query('roleInvites', {}),
roles : await this.store.findAll('role')
};
}
});
27 changes: 27 additions & 0 deletions app/templates/components/modals/confirm-event-transfer-modal.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div class="header">
{{t 'You are transferring this event. This action cannot be undone.'}}
<div class="muted small text">
{{t 'All the event rights will be transferred to another user'}}
</div>
</div>
<div class="content">
<form class="ui {{if isLoading 'loading'}} form" id="eventTransferForm" autocomplete="off" {{action 'submit' on='submit' preventDefault=true}}>
<div class="field">
<label class="required">
{{t 'User Email'}}
</label>
{{input type='text' name='user_email' value=currentInvite.email}}
</div>
<div class="field">
{{ui-checkbox label=(t 'Please tick the box to agree and press TRANSFER') type="checkbox" checked=checked onChange=(action (mut checked))}}
</div>
</form>
</div>
<div class="actions">
<button type="button" class="ui black button" {{action 'close'}}>
{{t 'Cancel'}}
</button>
<button type="submit" form="eventTransferForm" class="ui red button {{if (not checked) 'disabled'}}">
{{t 'Transfer'}}
</button>
</div>
24 changes: 24 additions & 0 deletions app/templates/components/modals/event-transfer-modal.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div class="header">
{{t 'Are you sure you would like to transfer this event?'}}
<div class="muted small text">
{{t 'Transferring the event to another user will lead to you losing all the owner rights.'}}
</div>
</div>
<div class="content">
<div class="ui {{if isLoading 'loading'}} form" autocomplete="off">
<div class="field">
<div class="label">
{{t 'Please enter the event-name to confirm that you want to transfer the event'}}
</div>
{{input type='text' name='confirm_name' value=confirmEventName required=true}}
</div>
</div>
</div>
<div class="actions">
<button type="button" class="ui black button" {{action 'close'}}>
{{t 'Cancel'}}
</button>
<button {{action openConfirmEventTransferModal}} class="ui red button {{if isNameDifferent 'disabled'}}">
{{t 'Proceed'}}
</button>
</div>
3 changes: 3 additions & 0 deletions app/templates/events/view.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
{{#link-to 'events.view.export' class='item'}}
{{t 'Export'}}
{{/link-to}}
{{#link-to 'events.view.settings' class='item'}}
{{t 'Settings'}}
{{/link-to}}
{{/tabbed-navigation}}
</div>
</div>
Expand Down
10 changes: 10 additions & 0 deletions app/templates/events/view/settings.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="row">
<p>
{{t 'Transfer ownership of this event to another user. You\'ll lose all the owner rights once they accept the ownership.'}}
</p>
<button {{action 'openEventTransferModal' model.event.id model.event.name}} class='ui red button'>
{{t 'Transfer Ownership'}}
</button>
</div>
{{modals/event-transfer-modal isLoading=isLoading isOpen=isEventTransferModalOpen confirmEventName=confirmEventName eventName=eventName openConfirmEventTransferModal=(action 'openConfirmEventTransferModal') transferEvent=(action 'transferEvent' model)}}
{{modals/confirm-event-transfer-modal currentInvite=currentInvite isLoading=isLoading isOpen=isConfirmEventTransferModalOpen checked=checked transferEvent=(action 'transferEvent')}}