-/* sidebar_editor.js */
-const editor = {};
-var vm;
+/* boxes-editor.js */
+const boxesEditor = {};
+boxesEditor.run = function run (params) {
-Vue.component('box-editor', {
- template: '#box-editor',
- props: {
- box: Object,
- },
- data: function () {
- return { message: "", };
- },
- computed: {
- nameNg: function () { return !this.box.name.length; },
- },
- methods: {
- save: function save() {
- // create/update box
- this.message = "";
- newslash.admin.updateBox(this.box).then(
- (response) => { // success
- if (response.error) {
- this.message = "error: " + response.message;
- return;
- }
- if (!response.id) {
- this.message = "error: " + response.message;
- return;
- }
- this.message = "saved.";
- if (this.box.id == 0) {
+ var vm;
+
+ Vue.component('box-editor', {
+ template: '#box-editor',
+ props: {
+ box: Object,
+ },
+ data: function () {
+ return { message: "", };
+ },
+ computed: {
+ nameNg: function () { return !this.box.name.length; },
+ },
+ methods: {
+ save: function save() {
+ // create/update box
+ this.message = "";
+ newslash.admin.updateBox(this.box).then(
+ (response) => { // success
+ if (response.error) {
+ this.message = "error: " + response.message;
+ return;
+ }
+ if (!response.id) {
+ this.message = "error: " + response.message;
+ return;
+ }
+ this.message = "saved.";
+ if (this.box.id == 0) {
this.box.id = response.id;
+ }
+ this.box.edited = false;
+ },
+ (response) => { // fail
+ this.message = "error";
}
- this.box.edited = false;
- },
- (response) => { // fail
- this.message = "error";
+ );
+ },
+ close: function close() {
+ this.box.editing = false;
+ this.message = "";
+ if (this.box.id == 0) {
+ vm.boxItems.pop();
}
- );
+ },
},
- close: function close() {
- this.box.editing = false;
- this.message = "";
- if (this.box.id == 0) {
- vm.boxItems.pop();
- }
- },
- },
-});
-
+ });
-editor.run = function run (params) {
const data = {
message: '',
boxItems: [],
-/* sidebar_editor.js */
+/* feeds-editor.js */
var feedsEditor = {};
-var vm;
-Vue.component('feed-editor', {
- template: '#feed-editor',
- props: {
- feed: Object,
- },
- data: function () {
- return { message: "" };
- },
- methods: {
- save: function save() {
- // create/update feed
- this.message = "";
- var postData = {
- action: this.feed.feed_id ? "update" : "create",
- url: this.feed.url,
- title: this.feed.title,
- name: this.feed.name,
- description: this.feed.description,
- feed_id: this.feed.feed_id,
- };
- this.$http.post("/api/v1/admin/feed", postData).then(
- (response) => { // success
- if (response.body.error) {
- this.message = "error: " + response.body.message;
- return;
- }
- if (!response.body.feed_id) {
- this.message = "error: " + response.body.message;
- return;
- }
- this.message = "saved.";
- if (this.feed.feed_id == 0) {
- this.feed.feed_id = response.body.feed_id;
- }
- },
- (response) => { // fail
- this.message = "error";
- return;
- }
- );
+feedsEditor.run = function run (params) {
+ var vm;
+
+ Vue.component('feed-editor', {
+ template: '#feed-editor',
+ props: {
+ feed: Object,
},
- close: function close() {
- this.feed.editing = false;
- this.message = "";
- if (this.feed.feed_id == 0) {
- vm.feeds.pop();
- }
+ data: function () {
+ return { message: "" };
},
- fetch: function fetch() {
- this.message = "";
- var postData = {
- action: "fetch",
- url: this.feed.url,
- };
- this.$http.post("/api/v1/admin/feed", postData).then(
- (response) => { // success
- if (response.body.error) {
- this.message = "error: " + response.body.message;
+ methods: {
+ save: function save() {
+ // create/update feed
+ this.message = "";
+ var postData = {
+ action: this.feed.feed_id ? "update" : "create",
+ url: this.feed.url,
+ title: this.feed.title,
+ name: this.feed.name,
+ description: this.feed.description,
+ feed_id: this.feed.feed_id,
+ };
+ this.$http.post("/api/v1/admin/feed", postData).then(
+ (response) => { // success
+ if (response.body.error) {
+ this.message = "error: " + response.body.message;
+ return;
+ }
+ if (!response.body.feed_id) {
+ this.message = "error: " + response.body.message;
+ return;
+ }
+ this.message = "saved.";
+ if (this.feed.feed_id == 0) {
+ this.feed.feed_id = response.body.feed_id;
+ }
+ },
+ (response) => { // fail
+ this.message = "error";
return;
}
- this.feed.url = response.body.item.url;
- this.feed.title = response.body.item.title;
- this.feed.description = response.body.item.description;
- },
- (response) => { // fail
+ );
+ },
+ close: function close() {
+ this.feed.editing = false;
+ this.message = "";
+ if (this.feed.feed_id == 0) {
+ vm.feeds.pop();
+ }
+ },
+ fetch: function fetch() {
+ this.message = "";
+ var postData = {
+ action: "fetch",
+ url: this.feed.url,
+ };
+ this.$http.post("/api/v1/admin/feed", postData).then(
+ (response) => { // success
+ if (response.body.error) {
+ this.message = "error: " + response.body.message;
+ return;
+ }
+ this.feed.url = response.body.item.url;
+ this.feed.title = response.body.item.title;
+ this.feed.description = response.body.item.description;
+ },
+ (response) => { // fail
this.message = "error: " + response.body.message;
return;
- }
- );
-
+ }
+ );
+
+ },
},
- },
-});
-
+ });
-feedsEditor.run = function run (params) {
var data = {
message: '',
feeds: [],