7021433185
This PR adds a new {{template-anchor}} component. This component lets you specify a 'href template' in a handlebars like format instead of a normal string href. This template will be interpolated with the contents of a vars="" attribute. Also contains code to add an extra UI Setting to be able to store a template to be used for this anchor in localStorage
44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
import Controller from '@ember/controller';
|
|
import { get, set } from '@ember/object';
|
|
import { inject as service } from '@ember/service';
|
|
|
|
export default Controller.extend({
|
|
repo: service('settings'),
|
|
dom: service('dom'),
|
|
actions: {
|
|
key: function(e) {
|
|
switch (true) {
|
|
case e.keyCode === 13:
|
|
// disable ENTER
|
|
e.preventDefault();
|
|
}
|
|
},
|
|
change: function(e, value, item) {
|
|
const event = get(this, 'dom').normalizeEvent(e, value);
|
|
// TODO: Switch to using forms like the rest of the app
|
|
// setting utils/form/builder for things to be done before we
|
|
// can do that. For the moment just do things normally its a simple
|
|
// enough form at the moment
|
|
|
|
const target = event.target;
|
|
const blocking = get(this, 'item.client.blocking');
|
|
switch (target.name) {
|
|
case 'client[blocking]':
|
|
if (typeof blocking === 'undefined') {
|
|
set(this, 'item.client', {});
|
|
}
|
|
set(this, 'item.client.blocking', !blocking);
|
|
this.send('update', get(this, 'item'));
|
|
break;
|
|
case 'urls[service]':
|
|
if (typeof get(this, 'item.urls') === 'undefined') {
|
|
set(this, 'item.urls', {});
|
|
}
|
|
set(this, 'item.urls.service', target.value);
|
|
this.send('update', get(this, 'item'));
|
|
break;
|
|
}
|
|
},
|
|
},
|
|
});
|