diff --git a/src/web/app/desktop/mixins/index.js b/src/web/app/desktop/mixins/index.js index a7a3eb948..e0c94ec5e 100644 --- a/src/web/app/desktop/mixins/index.js +++ b/src/web/app/desktop/mixins/index.js @@ -1 +1,2 @@ require('./user-preview'); +require('./widget'); diff --git a/src/web/app/desktop/mixins/widget.js b/src/web/app/desktop/mixins/widget.js new file mode 100644 index 000000000..d21811fa2 --- /dev/null +++ b/src/web/app/desktop/mixins/widget.js @@ -0,0 +1,27 @@ +import * as riot from 'riot'; + +// ミックスインにオプションを渡せないのアレ +// SEE: https://github.com/riot/riot/issues/2434 + +riot.mixin('widget', { + init: function() { + this.mixin('i'); + this.mixin('api'); + + this.id = this.opts.id; + + Object.keys(this.data).forEach(prop => { + this.data[prop] = this.opts.data.hasOwnProperty(prop) ? this.opts.data[prop] : this.data[prop]; + }); + }, + + save: function() { + this.api('i/update_home', { + id: this.id, + data: this.data + }).then(() => { + this.I.client_settings.home.find(w => w.id == this.id).data = this.data; + this.I.update(); + }); + } +}); diff --git a/src/web/app/desktop/tags/home-widgets/activity.tag b/src/web/app/desktop/tags/home-widgets/activity.tag index 00cf4ea20..9c4eeb615 100644 --- a/src/web/app/desktop/tags/home-widgets/activity.tag +++ b/src/web/app/desktop/tags/home-widgets/activity.tag @@ -2,8 +2,8 @@
%i18n:desktop.tags.mk-activity-home-widget.title%
%i18n:common.loading%
%i18n:desktop.tags.mk-server-home-widget.title%
%i18n:common.loading%