-
Notifications
You must be signed in to change notification settings - Fork 326
/
sub-settings-form.js
55 lines (47 loc) · 1.45 KB
/
sub-settings-form.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import BufferedProxy from 'ember-buffered-proxy/proxy';
import Component from '@ember/component';
import SubSettings from 'api-umbrella-admin-ui/models/api/sub-settings';
import { computed } from '@ember/object';
import { getOwner } from '@ember/application';
export default Component.extend({
openModal: false,
init() {
this._super(...arguments);
this.httpMethodOptions = [
{ id: 'any', name: 'Any' },
{ id: 'GET', name: 'GET' },
{ id: 'POST', name: 'POST' },
{ id: 'PUT', name: 'PUT' },
{ id: 'DELETE', name: 'DELETE' },
{ id: 'HEAD', name: 'HEAD' },
{ id: 'TRACE', name: 'TRACE' },
{ id: 'OPTIONS', name: 'OPTIONS' },
{ id: 'CONNECT', name: 'CONNECT' },
{ id: 'PATCH', name: 'PATCH' },
];
},
modalTitle: computed('model.isNew', function() {
if(this.model.isNew) {
return 'Add Sub-URL Request Settings';
} else {
return 'Edit Sub-URL Request Settings';
}
}),
bufferedModel: computed('model', function() {
let owner = getOwner(this).ownerInjection();
return BufferedProxy.extend(SubSettings.validationClass).create(owner, { content: this.model });
}),
actions: {
submit() {
this.bufferedModel.applyChanges();
if(this.model.isNew) {
this.collection.pushObject(this.model);
}
this.set('openModal', false);
},
closed() {
this.bufferedModel.discardChanges();
this.set('openModal', false);
},
},
});