Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: View Action for Speaker #5390

Merged
merged 12 commits into from
Oct 28, 2020
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
4 changes: 2 additions & 2 deletions app/controllers/events/view/speakers/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
}

@action
viewSpeaker(id) {
this.transitionToRoute('events.view.speakers.edit', id);
viewSpeaker(speaker) {
this.transitionToRoute('public.speaker.view', speaker.event.get('identifier'), speaker.id);
}

@action
Expand Down
9 changes: 9 additions & 0 deletions app/controllers/public/speaker/view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Controller from '@ember/controller';
import { computed } from '@ember/object';

export default class extends Controller {
@computed('speaker.isAuthenticated', 'authManager.currentUser.email', 'authManager.currentUser.isAdmin', 'model.speakers')
get showEditSection() {
return this.session.isAuthenticated && (this.authManager.currentUser.isAdmin || this.model.email === this.authManager.currentUser.email);
}
}
3 changes: 3 additions & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ Router.map(function() {
this.route('session', function() {
this.route('view', { path: '/:session_id' });
});
this.route('speaker', function() {
this.route('view', { path: '/:speaker_id' });
});
this.route('cfs', { path: '/cfs/:speaker_call_hash' }, function() {
this.route('new-speaker');
this.route('new-session');
Expand Down
13 changes: 13 additions & 0 deletions app/routes/public/speaker/view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import classic from 'ember-classic-decorator';
import Route from '@ember/routing/route';

@classic
export default class ViewRoute extends Route {
titleToken(model) {
return model.title;
}

model(params) {
return this.store.findRecord('speaker', params.speaker_id);
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
{{this.record}}
<div class="hidden ui divider"></div>
<br><br>
divyamtayal marked this conversation as resolved.
Show resolved Hide resolved
<div class="ui horizontal compact basic buttons">
<LinkTo @route="events.view.speakers.edit" @model={{this.extraRecords.id}}>
<UiPopup @content={{t "View"}} @class="ui icon button" @click={{action this.props.actions.viewSpeaker this.extraRecords.id}} @position="left center">
<i class="unhide icon"></i>
</UiPopup>
</LinkTo>
<LinkTo @route="events.view.speakers.edit" @model={{this.extraRecords.id}}>
<UiPopup @content={{t "Edit"}} @class="ui icon button" @click={{action this.props.actions.editSpeaker this.extraRecords.id}} @position="left center">
<i class="edit icon"></i>
</UiPopup>
</LinkTo>
<UiPopup @content={{t "View"}} @class="ui icon button" @click={{action this.props.actions.viewSpeaker this.extraRecords}} @position="left center">
<i class="unhide icon"></i>
</UiPopup>
<UiPopup @content={{t "Edit"}} @class="ui icon button" @click={{action this.props.actions.editSpeaker this.extraRecords.id }} @position="left center">
<i class="edit icon"></i>
</UiPopup>
<UiPopup @content={{t "Delete"}} @click={{action (confirm (t "Are you sure you would like to delete this Speaker?") (action this.props.actions.deleteSpeaker this.extraRecords.id))}} @class="ui icon button" @position="left center">
<i class="trash icon"></i>
</UiPopup>
Expand Down
20 changes: 20 additions & 0 deletions app/templates/public/speaker/view.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<div class="ui container">
{{#if this.showEditSection}}
<div class="ui row mb-8">
<LinkTo
@route="public.cfs.edit-speaker"
@models={{array this.model.event.id this.model.id}}>
<button
class="ui blue button {{if this.device.isMobile 'fluid' 'right floated'}}">{{t 'Edit Speaker'}}</button>
{{#if this.device.isMobile}}
<div class="ui hidden fitted divider"></div>
{{/if}}
</LinkTo>
</div>
{{/if}}
<div class="ui row">
<Public::SpeakerItem
@speaker={{this.model}}
/>
</div>
</div>
11 changes: 11 additions & 0 deletions tests/unit/routes/public/speaker/view-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

module('Unit | Route | public/speaker/view', function(hooks) {
setupTest(hooks);

test('it exists', function(assert) {
const route = this.owner.lookup('route:public/speaker/view');
assert.ok(route);
});
});