Repository URL to install this package:
|
Version:
0.0.9 ▾
|
import * as tslib_1 from "tslib";
/**
* @todo rewrite as class
*/
import { observable, action, computed } from 'xmobx/mobx';
import { oneStorage } from '@skava/persistence';
import { oneRouter } from '@skava/router';
import transformLocale from './transform';
import * as fixture from './fixture';
const transformedFixture = transformLocale(fixture);
const { list } = transformedFixture;
const languages = list;
export class LocaleContainer {
constructor() {
/**
* @todo @name item = also find out if it's used? maybe sidebar menu?
*/
this.list = this.item;
this.languages = languages;
this.isModalVisible = false;
}
get item() {
return oneStorage.has('locale_lang') ? oneStorage.get('locale_lang') : languages[0];
}
handleModalClick(event) {
this.isModalVisible = true;
}
handleCloseModal(event) {
this.isModalVisible = false;
}
handleClick(index) {
this.isModalVisible = false;
this.list = languages[index];
oneStorage.set('locale_lang', this.list);
oneRouter.reload();
}
handleClickFor(index) {
return () => {
this.handleClick(index);
// @todo refetch the active api without reload (future implmentation)
// client.resetStore()
};
}
}
tslib_1.__decorate([
observable.ref
], LocaleContainer.prototype, "list", void 0);
tslib_1.__decorate([
observable.ref
], LocaleContainer.prototype, "languages", void 0);
tslib_1.__decorate([
observable
], LocaleContainer.prototype, "isModalVisible", void 0);
tslib_1.__decorate([
computed
], LocaleContainer.prototype, "item", null);
tslib_1.__decorate([
action.bound
], LocaleContainer.prototype, "handleModalClick", null);
tslib_1.__decorate([
action.bound
], LocaleContainer.prototype, "handleCloseModal", null);
tslib_1.__decorate([
action.bound
], LocaleContainer.prototype, "handleClick", null);
tslib_1.__decorate([
action.bound
], LocaleContainer.prototype, "handleClickFor", null);
//# sourceMappingURL=LocaleContainer.js.map