Cleanup semi colons and add rule

This commit is contained in:
Sytone 2021-06-02 15:32:13 -07:00
parent 194b1291e6
commit 714c01403c
3 changed files with 102 additions and 102 deletions

View File

@ -34,17 +34,17 @@
</template> </template>
<script> <script>
import LabelTask from '../../models/labelTask'; import LabelTask from '../../models/labelTask'
import LabelModel from '../../models/label'; import LabelModel from '../../models/label'
import { HAS_TASKS } from '@/store/mutation-types'; import { HAS_TASKS } from '@/store/mutation-types'
// import Nothing from "@/components/misc/nothing"; // import Nothing from "@/components/misc/nothing";
import ListService from '../../services/list'; import ListService from '../../services/list'
import TaskService from '../../services/task'; import TaskService from '../../services/task'
import TaskModel from '../../models/task'; import TaskModel from '../../models/task'
import LabelService from '../../services/label'; import LabelService from '../../services/label'
import LabelTaskService from '../../services/labelTask'; import LabelTaskService from '../../services/labelTask'
export default { export default {
name: 'add-task', name: 'add-task',
@ -57,7 +57,7 @@ export default {
labelTaskService: LabelTaskService, labelTaskService: LabelTaskService,
listIdForNewTask: undefined, listIdForNewTask: undefined,
validListIdAvailable: false, validListIdAvailable: false,
}; }
}, },
components: {}, components: {},
props: { props: {
@ -67,68 +67,68 @@ export default {
}, },
}, },
created() { created() {
this.listService = new ListService(); this.listService = new ListService()
this.taskService = new TaskService(); this.taskService = new TaskService()
this.labelService = new LabelService(); this.labelService = new LabelService()
this.labelTaskService = new LabelTaskService(); this.labelTaskService = new LabelTaskService()
}, },
beforeMount() { beforeMount() {
console.log(this.listId); console.log(this.listId)
if (this.listId !== undefined) { if (this.listId !== undefined) {
this.listIdForNewTask = this.listId; this.listIdForNewTask = this.listId
this.validListIdAvailable = true; this.validListIdAvailable = true
} }
}, },
methods: { methods: {
addTask() { addTask() {
if (this.newTaskText === '') { if (this.newTaskText === '') {
this.showError = true; this.showError = true
return; return
} }
this.showError = false; this.showError = false
const task = new TaskModel({ const task = new TaskModel({
title: this.newTaskText, title: this.newTaskText,
listId: this.listIdForNewTask, listId: this.listIdForNewTask,
}); })
this.taskService this.taskService
.create(task) .create(task)
.then(task => { .then(task => {
this.newTaskText = ''; this.newTaskText = ''
// Check if the task has words starting with ~ in the title and make them to labels // Check if the task has words starting with ~ in the title and make them to labels
const parts = task.title.split(' ~'); const parts = task.title.split(' ~')
// The first element will always contain the title, even if there is no occurrence of ~ // The first element will always contain the title, even if there is no occurrence of ~
if (parts.length > 1) { if (parts.length > 1) {
// First, create an unresolved promise for each entry in the array to wait // First, create an unresolved promise for each entry in the array to wait
// until all labels are added to update the task title once again // until all labels are added to update the task title once again
let labelAddings = []; let labelAddings = []
let labelAddsToWaitFor = []; let labelAddsToWaitFor = []
parts.forEach((p, index) => { parts.forEach((p, index) => {
if (index < 1) { if (index < 1) {
return; return
} }
labelAddsToWaitFor.push( labelAddsToWaitFor.push(
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
labelAddings.push({ resolve: resolve, reject: reject }); labelAddings.push({ resolve: resolve, reject: reject })
}), }),
); )
}); })
// Then do everything that is involved in finding, creating and adding the label to the task // Then do everything that is involved in finding, creating and adding the label to the task
parts.forEach((p, index) => { parts.forEach((p, index) => {
if (index < 1) { if (index < 1) {
return; return
} }
// The part up until the next space // The part up until the next space
const labelTitle = p.split(' ')[0]; const labelTitle = p.split(' ')[0]
// Don't create an empty label // Don't create an empty label
if (labelTitle === '') { if (labelTitle === '') {
return; return
} }
// Check if the label exists // Check if the label exists
@ -140,58 +140,58 @@ export default {
const labelTask = new LabelTask({ const labelTask = new LabelTask({
taskId: task.id, taskId: task.id,
labelId: res[0].id, labelId: res[0].id,
}); })
this.labelTaskService this.labelTaskService
.create(labelTask) .create(labelTask)
.then(result => { .then(result => {
task.labels.push(res[0]); task.labels.push(res[0])
// Remove the label text from the task title // Remove the label text from the task title
task.title = task.title.replace(` ~${labelTitle}`, ''); task.title = task.title.replace(` ~${labelTitle}`, '')
// Make the promise done (the one with the index 0 does not exist) // Make the promise done (the one with the index 0 does not exist)
labelAddings[index - 1].resolve(result); labelAddings[index - 1].resolve(result)
}) })
.catch(e => { .catch(e => {
this.error(e, this); this.error(e, this)
}); })
} else { } else {
// label not found, create it // label not found, create it
const label = new LabelModel({ title: labelTitle }); const label = new LabelModel({ title: labelTitle })
this.labelService this.labelService
.create(label) .create(label)
.then(res => { .then(res => {
const labelTask = new LabelTask({ const labelTask = new LabelTask({
taskId: task.id, taskId: task.id,
labelId: res.id, labelId: res.id,
}); })
this.labelTaskService this.labelTaskService
.create(labelTask) .create(labelTask)
.then(result => { .then(result => {
task.labels.push(res); task.labels.push(res)
// Remove the label text from the task title // Remove the label text from the task title
task.title = task.title.replace( task.title = task.title.replace(
` ~${labelTitle}`, ` ~${labelTitle}`,
'', '',
); )
// Make the promise done (the one with the index 0 does not exist) // Make the promise done (the one with the index 0 does not exist)
labelAddings[index - 1].resolve(result); labelAddings[index - 1].resolve(result)
}) })
.catch(e => { .catch(e => {
this.error(e, this); this.error(e, this)
}); })
}) })
.catch(e => { .catch(e => {
this.error(e, this); this.error(e, this)
}); })
} }
}) })
.catch(e => { .catch(e => {
this.error(e, this); this.error(e, this)
}); })
}); })
// This waits to update the task until all labels have been added and the title has // This waits to update the task until all labels have been added and the title has
// been modified to remove each label text // been modified to remove each label text
@ -199,19 +199,19 @@ export default {
this.taskService this.taskService
.update(task) .update(task)
.then(() => { .then(() => {
this.$store.commit(HAS_TASKS, true); this.$store.commit(HAS_TASKS, true)
}) })
.catch(e => { .catch(e => {
this.error(e, this); this.error(e, this)
}); })
}); })
} }
this.$emit('taskAdded', task); this.$emit('taskAdded', task)
}) })
.catch(e => { .catch(e => {
this.error(e, this); this.error(e, this)
}); })
}, },
}, },
}; }
</script> </script>

View File

@ -34,9 +34,9 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex'; import { mapState } from 'vuex'
import ShowTasks from './tasks/ShowTasks'; import ShowTasks from './tasks/ShowTasks'
import AddTask from '../components/tasks/add-task'; import AddTask from '../components/tasks/add-task'
export default { export default {
name: 'Home', name: 'Home',
@ -51,7 +51,7 @@ export default {
tasks: [], tasks: [],
defaultListId: undefined, defaultListId: undefined,
showTasksKey: 0, showTasksKey: 0,
}; }
}, },
created() { created() {
//TODO: Load the value from user settings. Until then it will not render the add task component. //TODO: Load the value from user settings. Until then it will not render the add task component.
@ -65,23 +65,23 @@ export default {
hasTasks: state => state.hasTasks, hasTasks: state => state.hasTasks,
defaultNamespaceId: state => { defaultNamespaceId: state => {
if (state.namespaces.namespaces.length === 0) { if (state.namespaces.namespaces.length === 0) {
return 0; return 0
} }
return state.namespaces.namespaces[0].id; return state.namespaces.namespaces[0].id
}, },
hasLists: state => { hasLists: state => {
if (state.namespaces.namespaces.length === 0) { if (state.namespaces.namespaces.length === 0) {
return false; return false
} }
return state.namespaces.namespaces[0].lists.length > 0; return state.namespaces.namespaces[0].lists.length > 0
}, },
}), }),
methods: { methods: {
updateTaskList() { updateTaskList() {
this.showTasksKey += 1; this.showTasksKey += 1
}, },
}, },
}; }
</script> </script>

View File

@ -165,21 +165,21 @@
</template> </template>
<script> <script>
import TaskService from '../../../services/task'; import TaskService from '../../../services/task'
import TaskModel from '../../../models/task'; import TaskModel from '../../../models/task'
import LabelTaskService from '../../../services/labelTask'; import LabelTaskService from '../../../services/labelTask'
import LabelService from '../../../services/label'; import LabelService from '../../../services/label'
import EditTask from '../../../components/tasks/edit-task'; import EditTask from '../../../components/tasks/edit-task'
import AddTask from '../../../components/tasks/add-task'; import AddTask from '../../../components/tasks/add-task'
import SingleTaskInList from '../../../components/tasks/partials/singleTaskInList'; import SingleTaskInList from '../../../components/tasks/partials/singleTaskInList'
import taskList from '../../../components/tasks/mixins/taskList'; import taskList from '../../../components/tasks/mixins/taskList'
import { saveListView } from '@/helpers/saveListView'; import { saveListView } from '@/helpers/saveListView'
import Rights from '../../../models/rights.json'; import Rights from '../../../models/rights.json'
import { mapState } from 'vuex'; import { mapState } from 'vuex'
import FilterPopup from '@/components/list/partials/filter-popup'; import FilterPopup from '@/components/list/partials/filter-popup'
import { HAS_TASKS } from '@/store/mutation-types'; import { HAS_TASKS } from '@/store/mutation-types'
import Nothing from '@/components/misc/nothing'; import Nothing from '@/components/misc/nothing'
export default { export default {
name: 'List', name: 'List',
@ -195,7 +195,7 @@ export default {
labelService: LabelService, labelService: LabelService,
ctaVisible: false, ctaVisible: false,
}; }
}, },
mixins: [taskList], mixins: [taskList],
components: { components: {
@ -206,56 +206,56 @@ export default {
AddTask, AddTask,
}, },
created() { created() {
this.taskService = new TaskService(); this.taskService = new TaskService()
this.labelService = new LabelService(); this.labelService = new LabelService()
this.labelTaskService = new LabelTaskService(); this.labelTaskService = new LabelTaskService()
// Save the current list view to local storage // Save the current list view to local storage
// We use local storage and not vuex here to make it persistent across reloads. // We use local storage and not vuex here to make it persistent across reloads.
saveListView(this.$route.params.listId, this.$route.name); saveListView(this.$route.params.listId, this.$route.name)
}, },
computed: mapState({ computed: mapState({
canWrite: state => state.currentList.maxRight > Rights.READ, canWrite: state => state.currentList.maxRight > Rights.READ,
list: state => state.currentList, list: state => state.currentList,
}), }),
mounted() { mounted() {
this.$nextTick(() => (this.ctaVisible = true)); this.$nextTick(() => (this.ctaVisible = true))
}, },
methods: { methods: {
// This function initializes the tasks page and loads the first page of tasks // This function initializes the tasks page and loads the first page of tasks
initTasks(page, search = '') { initTasks(page, search = '') {
this.taskEditTask = null; this.taskEditTask = null
this.isTaskEdit = false; this.isTaskEdit = false
this.loadTasks(page, search); this.loadTasks(page, search)
}, },
updateTaskList(task) { updateTaskList(task) {
this.tasks.push(task); this.tasks.push(task)
this.sortTasks(); this.sortTasks()
this.$store.commit(HAS_TASKS, true); this.$store.commit(HAS_TASKS, true)
}, },
editTask(id) { editTask(id) {
// Find the selected task and set it to the current object // Find the selected task and set it to the current object
let theTask = this.getTaskById(id); // Somehow this does not work if we directly assign this to this.taskEditTask let theTask = this.getTaskById(id) // Somehow this does not work if we directly assign this to this.taskEditTask
this.taskEditTask = theTask; this.taskEditTask = theTask
this.isTaskEdit = true; this.isTaskEdit = true
}, },
getTaskById(id) { getTaskById(id) {
for (const t in this.tasks) { for (const t in this.tasks) {
if (this.tasks[t].id === parseInt(id)) { if (this.tasks[t].id === parseInt(id)) {
return this.tasks[t]; return this.tasks[t]
} }
} }
return {}; // FIXME: This should probably throw something to make it clear to the user noting was found return {} // FIXME: This should probably throw something to make it clear to the user noting was found
}, },
updateTasks(updatedTask) { updateTasks(updatedTask) {
for (const t in this.tasks) { for (const t in this.tasks) {
if (this.tasks[t].id === updatedTask.id) { if (this.tasks[t].id === updatedTask.id) {
this.$set(this.tasks, t, updatedTask); this.$set(this.tasks, t, updatedTask)
break; break
} }
} }
this.sortTasks(); this.sortTasks()
}, },
}, },
}; }
</script> </script>