mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 21:34:24 +00:00
Restructuring for new way of installing libreevent
This commit is contained in:
64
src/web/backend/plugins/others/poll/js/settings.js
Normal file
64
src/web/backend/plugins/others/poll/js/settings.js
Normal file
@@ -0,0 +1,64 @@
|
||||
/* eslint-disable no-undef */
|
||||
const { createApp } = Vue;
|
||||
|
||||
createApp( {
|
||||
data() {
|
||||
return {
|
||||
polls: {},
|
||||
newPoll: {},
|
||||
operation: 'Add new',
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
getData() {
|
||||
fetch( '/admin/plugins/polls/getData' ).then( response => {
|
||||
response.json().then( data => {
|
||||
this.polls = data;
|
||||
this.newPoll = {};
|
||||
} );
|
||||
} );
|
||||
},
|
||||
save() {
|
||||
if ( this.newPoll.comment && this.newPoll.display && this.newPoll.id ) {
|
||||
this.polls[ this.newPoll.id ] = this.newPoll;
|
||||
let fetchOptions = {
|
||||
method: 'post',
|
||||
body: JSON.stringify( this.polls ),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'charset': 'utf-8'
|
||||
},
|
||||
};
|
||||
fetch( '/admin/plugins/polls/save', fetchOptions ).then( response => {
|
||||
if ( response.status !== 200 ) {
|
||||
alert( 'there was an error updating' );
|
||||
}
|
||||
} );
|
||||
this.closePopup();
|
||||
this.getData();
|
||||
} else {
|
||||
alert( 'Not all required fields are filled out!' );
|
||||
}
|
||||
},
|
||||
closePopup() {
|
||||
$( '#popup' ).fadeOut( 500 );
|
||||
$( 'body' ).removeClass( 'menuOpen' );
|
||||
this.getData();
|
||||
},
|
||||
addPoll () {
|
||||
this.newPoll = { 'allowAdding': true };
|
||||
this.operation = 'Add new';
|
||||
$( '#popup' ).fadeIn( 500 );
|
||||
$( 'body' ).addClass( 'menuOpen' );
|
||||
},
|
||||
editPoll ( pollID ) {
|
||||
this.operation = 'Edit';
|
||||
this.newPoll = this.polls[ pollID ];
|
||||
$( '#popup' ).fadeIn( 500 );
|
||||
$( 'body' ).addClass( 'menuOpen' );
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getData();
|
||||
}
|
||||
} ).mount( '#app' );
|
||||
Reference in New Issue
Block a user