2020-09-30 11:33:01 +00:00
|
|
|
import { computed } from '@ember/object';
|
|
|
|
import { or } from '@ember/object/computed';
|
2020-09-18 10:14:06 +00:00
|
|
|
import attr from 'ember-data/attr';
|
|
|
|
|
|
|
|
import Fragment from 'ember-data-model-fragments/fragment';
|
|
|
|
|
2020-09-30 11:33:01 +00:00
|
|
|
export const schema = {
|
|
|
|
Name: {
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
HeaderType: {
|
|
|
|
allowedValues: ['Exact', 'Prefix', 'Suffix', 'Regex', 'Present'],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-09-18 10:14:06 +00:00
|
|
|
export default Fragment.extend({
|
|
|
|
Name: attr('string'),
|
|
|
|
|
|
|
|
Exact: attr('string'),
|
|
|
|
Prefix: attr('string'),
|
|
|
|
Suffix: attr('string'),
|
|
|
|
Regex: attr('string'),
|
2020-09-30 11:33:01 +00:00
|
|
|
Present: attr(), // this is a boolean but we don't want it to automatically be set to false
|
|
|
|
|
|
|
|
Value: or(...schema.HeaderType.allowedValues),
|
|
|
|
HeaderType: computed(...schema.HeaderType.allowedValues, function() {
|
|
|
|
return schema.HeaderType.allowedValues.find(prop => typeof this[prop] !== 'undefined');
|
|
|
|
}),
|
2020-09-18 10:14:06 +00:00
|
|
|
});
|