Merge branch 'develop' into feature-doc-links
This commit is contained in:
3 files changed
+33
-4
No files matched your search
@@ -1,7 +1,18 @@
|
||||
import GeneratedSessionModel from '../generated/models/session';
|
||||
import { computed } from '@ember/object';
|
||||
|
||||
export default class SessionModel extends GeneratedSessionModel {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
@computed('status')
|
||||
get isCancelable() {
|
||||
return this.status?.match(/(active)|(pending)/i);
|
||||
}
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,10 +4,26 @@ import { setupTest } from 'ember-qunit';
|
||||
module('Unit | Model | session', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let store = this.owner.lookup('service:store');
|
||||
let model = store.createRecord('session', {});
|
||||
assert.ok(model);
|
||||
assert.notOk(model.isCancelable);
|
||||
});
|
||||
|
||||
test('it allows cancellation of an active session', function(assert) {
|
||||
let store = this.owner.lookup('service:store');
|
||||
let model = store.createRecord('session', {
|
||||
status: 'active'
|
||||
});
|
||||
assert.ok(model.isCancelable);
|
||||
});
|
||||
|
||||
test('it allows cancellation of a pending session', function(assert) {
|
||||
let store = this.owner.lookup('service:store');
|
||||
let model = store.createRecord('session', {
|
||||
status: 'pending'
|
||||
});
|
||||
assert.ok(model.isCancelable);
|
||||
});
|
||||
});
|
||||
@@ -47,9 +47,11 @@
|
||||
<Rose::Badge>{{sessionAggregate.session.status}}</Rose::Badge>
|
||||
</row.cell>
|
||||
<row.cell>
|
||||
<Rose::Button @style="secondary" {{on "click" (route-action "cancelSession" sessionAggregate.session)}}>
|
||||
{{t "actions.cancel"}}
|
||||
</Rose::Button>
|
||||
{{#if sessionAggregate.session.isCancelable}}
|
||||
<Rose::Button @style="secondary" {{on "click" (route-action "cancelSession" sessionAggregate.session)}}>
|
||||
{{t "actions.cancel"}}
|
||||
</Rose::Button>
|
||||
{{/if}}
|
||||
</row.cell>
|
||||
</body.row>
|
||||
{{/each}}
|
||||
|
||||
Reference in new issue
Block a user