2023-03-14 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-14 13:18:55 +00:00
|
|
|
*/
|
|
|
|
|
2020-07-09 09:08:47 +00:00
|
|
|
import Component from '@ember/component';
|
|
|
|
import { set } from '@ember/object';
|
|
|
|
import Slotted from 'block-slots';
|
|
|
|
import chart from './chart.xstate';
|
|
|
|
|
|
|
|
export default Component.extend(Slotted, {
|
|
|
|
tagName: '',
|
2022-09-15 08:43:17 +00:00
|
|
|
ondelete: function () {
|
2020-07-09 09:08:47 +00:00
|
|
|
return this.onchange(...arguments);
|
|
|
|
},
|
2022-09-15 08:43:17 +00:00
|
|
|
onchange: function () {},
|
|
|
|
init: function () {
|
2020-07-09 09:08:47 +00:00
|
|
|
this._super(...arguments);
|
|
|
|
this.chart = chart;
|
|
|
|
},
|
|
|
|
actions: {
|
2022-09-15 08:43:17 +00:00
|
|
|
persist: function (data, e) {
|
2020-07-09 09:08:47 +00:00
|
|
|
if (e && typeof e.preventDefault === 'function') {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
set(this, 'data', data);
|
|
|
|
this.dispatch('PERSIST');
|
|
|
|
},
|
2022-09-15 08:43:17 +00:00
|
|
|
error: function (data, e) {
|
2022-08-08 09:51:02 +00:00
|
|
|
if (e && typeof e.preventDefault === 'function') {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
set(
|
|
|
|
this,
|
|
|
|
'error',
|
2022-09-15 08:43:17 +00:00
|
|
|
typeof data.error.errors !== 'undefined' ? data.error.errors.firstObject : data.error
|
2022-08-08 09:51:02 +00:00
|
|
|
);
|
|
|
|
this.dispatch('ERROR');
|
|
|
|
},
|
2020-07-09 09:08:47 +00:00
|
|
|
},
|
|
|
|
});
|