2018-02-03 21:20:50 +03:00
|
|
|
import Component from '@ember/component';
|
|
|
|
import layout from '../templates/components/koenig-card-html';
|
|
|
|
import {set} from '@ember/object';
|
|
|
|
|
|
|
|
export default Component.extend({
|
|
|
|
layout,
|
|
|
|
|
2018-02-15 18:57:44 +03:00
|
|
|
// attrs
|
2018-02-03 21:20:50 +03:00
|
|
|
payload: null,
|
2018-02-15 18:57:44 +03:00
|
|
|
isSelected: false,
|
|
|
|
isEditing: false,
|
|
|
|
|
|
|
|
// closure actions
|
2018-02-03 21:20:50 +03:00
|
|
|
saveCard: null,
|
|
|
|
|
|
|
|
init() {
|
|
|
|
this._super(...arguments);
|
|
|
|
|
|
|
|
if (!this.get('payload.html')) {
|
|
|
|
this.set('payload.html', '');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
updateHtml(html) {
|
2018-02-20 18:53:58 +03:00
|
|
|
this._updatePayloadAttr('html', html);
|
|
|
|
},
|
2018-02-03 21:20:50 +03:00
|
|
|
|
2018-02-20 18:53:58 +03:00
|
|
|
updateCaption(caption) {
|
|
|
|
this._updatePayloadAttr('caption', caption);
|
2018-02-03 21:20:50 +03:00
|
|
|
}
|
2018-02-20 18:53:58 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
_updatePayloadAttr(attr, value) {
|
|
|
|
let payload = this.get('payload');
|
|
|
|
let save = this.get('saveCard');
|
|
|
|
|
|
|
|
set(payload, attr, value);
|
|
|
|
|
|
|
|
// update the mobiledoc and stay in edit mode
|
|
|
|
save(payload, false);
|
2018-02-03 21:20:50 +03:00
|
|
|
}
|
|
|
|
});
|