Skip to content

Commit

Permalink
Merge pull request #98 from covidcanidoit/one-click-add-suggestion-fo…
Browse files Browse the repository at this point in the history
…r-vuetify-admin-table

[#54] fix one-click-add from suggestions to new vuetify admin activit…
  • Loading branch information
reptile18 committed Jun 5, 2020
2 parents 6e544ad + 627dbf1 commit 1a57c8a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 74 deletions.
8 changes: 6 additions & 2 deletions src/components/AdminActivityTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ import { db } from "@/db.js";
import { mapState, mapGetters } from "vuex";
export default {
props: ["incomingNewActivityName"],
watch: {
incomingNewActivityName: "newActivity"
},
data() {
return {
headers: [
Expand Down Expand Up @@ -141,9 +145,9 @@ export default {
}
},
methods: {
newActivity(activityName) {
newActivity() {
this.showNewActivityPrompt = true;
if (activityName) this.newActivityName = activityName;
if (this.incomingNewActivityName) this.newActivityName = this.incomingNewActivityName;
},
newActivityOk() {
let currentKey = Object.keys(this.activities).find(
Expand Down
74 changes: 2 additions & 72 deletions src/views/Admin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class="btn"
@click="toggleActivities"
>{{ showActivities ? "&#x25bc;" : "&#x25b6;" }} Activities</h2>
<AdminActivityTable v-show="showActivities"></AdminActivityTable>
<AdminActivityTable v-show="showActivities" :incomingNewActivityName="newActivityName"></AdminActivityTable>
</div>

<div>
Expand Down Expand Up @@ -227,11 +227,7 @@ export default {
showRiskLevels: false,
showUsers: false,
showSuggestions: false,
showNewActivityPrompt: false,
newActivityName: "",
activityAlreadyExistsError: false,
activitySlugToDelete: "",
confirmActivityDelete: false,
currentUser: undefined,
currentUserSettings: undefined
};
Expand Down Expand Up @@ -324,73 +320,7 @@ export default {
this.showSuggestions = !this.showSuggestions;
},
newActivity(activityName) {
this.showNewActivityPrompt = true;
if (activityName) this.newActivityName = activityName;
},
newActivityOk() {
let currentKey = Object.keys(this.activities).find(
key =>
this.activities[key].activityName.toLowerCase() ===
this.newActivityName.toLowerCase()
);
console.log("New Activity?", currentKey);
if (currentKey) {
this.activityAlreadyExistsError = true;
} else {
let activityName = this.newActivityName;
let activitySlug = this.slugify(activityName);
this.showNewActivityPrompt = false;
db.ref("content")
.child(this.currentCountry)
.child("activities")
.child(activitySlug)
.child("slug")
.set(activitySlug);
db.ref("content")
.child(this.currentCountry)
.child("activities")
.child(activitySlug)
.child("activityName")
.set(activityName);
db.ref("content")
.child(this.currentCountry)
.child("activities")
.child(activitySlug)
.child("disabled")
.set(true);
this.$router.push({
name: "AdminActivityEdit",
params: { activityName: activityName, slug: activitySlug }
});
}
},
activityAlreadyExistsErrorOk() {
this.newActivityName = "";
},
activityIsActive(disabled) {
if (disabled) return "mdi-eye-off";
else return "mdi-eye";
},
toggleActivityIsDisabled(activitySlug,state) {
state = !state;
db.ref("content")
.child(this.currentCountry)
.child("activities")
.child(activitySlug)
.child("disabled")
.set(state);
},
deleteActivity() {
db.ref("content")
.child(this.currentCountry)
.child("activities")
.child(this.activitySlugToDelete)
.remove();
this.confirmActivityDelete = false;
},
showConfirmActivityDelete(activitySlug) {
this.activitySlugToDelete = activitySlug;
this.confirmActivityDelete = true;
this.newActivityName = activityName;
},
deleteUser(userId) {
db.ref("userSettings")
Expand Down

0 comments on commit 1a57c8a

Please sign in to comment.