mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 05:14:23 +00:00
improve voting plugin - more updates incoming!
This commit is contained in:
@@ -6,7 +6,7 @@ body {
|
|||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background-color: lightgray;
|
background-color: rgb(114, 164, 173);
|
||||||
}
|
}
|
||||||
|
|
||||||
.title-area {
|
.title-area {
|
||||||
|
|||||||
@@ -62,18 +62,28 @@
|
|||||||
.entry {
|
.entry {
|
||||||
border: black 2px solid;
|
border: black 2px solid;
|
||||||
padding: 1% 10%;
|
padding: 1% 10%;
|
||||||
|
width: 40vw;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.selected {
|
.selected {
|
||||||
background-color: green;
|
background-color: green;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.comment {
|
||||||
|
width: 50%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="content" id="app">
|
<div class="content" id="app">
|
||||||
<div v-if="votingDetails.display">
|
<div v-if="votingDetails.display">
|
||||||
<h1>Voting on {{ votingDetails.display ?? 'untitled' }}</h1>
|
<h1>Voting on {{ votingDetails.display ?? 'untitled' }}</h1>
|
||||||
<p v-if="votingDetails.description">{{ votingDetails.description }}</p>
|
<p v-if="votingDetails.description" class="comment">{{ votingDetails.description }}</p>
|
||||||
<div style="margin-bottom: 1%;" v-if="votingDetails.allowAdding">
|
<div style="margin-bottom: 1%;" v-if="votingDetails.allowAdding">
|
||||||
<button onclick="location.href = '/'">Back to website</button>
|
<button onclick="location.href = '/'">Back to website</button>
|
||||||
<button @click="addSuggestion();">Add suggestion</button>
|
<button @click="addSuggestion();">Add suggestion</button>
|
||||||
|
|||||||
@@ -26,6 +26,22 @@ createApp( {
|
|||||||
},
|
},
|
||||||
save() {
|
save() {
|
||||||
if ( this.newSuggestion.comment && this.newSuggestion.title ) {
|
if ( this.newSuggestion.comment && this.newSuggestion.title ) {
|
||||||
|
let alreadyExists = false;
|
||||||
|
for ( let el in this.entries ) {
|
||||||
|
if ( this.entries[ el ][ 'title' ] === this.newSuggestion.title ) {
|
||||||
|
alreadyExists = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( alreadyExists ) {
|
||||||
|
if ( confirm( 'An element with the same title exists already. Do you really want to add another one?' ) ) {
|
||||||
|
if ( confirm( 'Are you really sure?' ) ) {
|
||||||
|
alreadyExists = true;
|
||||||
|
} else {
|
||||||
|
alreadyExists = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !alreadyExists ) {
|
||||||
let fetchOptions = {
|
let fetchOptions = {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
body: JSON.stringify( this.newSuggestion ),
|
body: JSON.stringify( this.newSuggestion ),
|
||||||
@@ -34,13 +50,14 @@ createApp( {
|
|||||||
'charset': 'utf-8'
|
'charset': 'utf-8'
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
fetch( '/polls/add/' + location.pathname.substring( 7 ), fetchOptions ).then( response => {
|
fetch( '/voting/add/' + location.pathname.substring( 8 ), fetchOptions ).then( response => {
|
||||||
if ( response.status !== 200 ) {
|
if ( response.status !== 200 ) {
|
||||||
alert( 'there was an error updating' );
|
alert( 'there was an error updating' );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
this.closePopup();
|
this.closePopup();
|
||||||
this.getData();
|
this.getData();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
alert( 'Not all required fields are filled out!' );
|
alert( 'Not all required fields are filled out!' );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user