forked from vikunja/frontend
Cleanup semi colons and add rule
This commit is contained in:
parent
194b1291e6
commit
714c01403c
|
@ -34,17 +34,17 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import LabelTask from '../../models/labelTask';
|
||||
import LabelModel from '../../models/label';
|
||||
import LabelTask from '../../models/labelTask'
|
||||
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 ListService from '../../services/list';
|
||||
import TaskService from '../../services/task';
|
||||
import TaskModel from '../../models/task';
|
||||
import LabelService from '../../services/label';
|
||||
import LabelTaskService from '../../services/labelTask';
|
||||
import ListService from '../../services/list'
|
||||
import TaskService from '../../services/task'
|
||||
import TaskModel from '../../models/task'
|
||||
import LabelService from '../../services/label'
|
||||
import LabelTaskService from '../../services/labelTask'
|
||||
|
||||
export default {
|
||||
name: 'add-task',
|
||||
|
@ -57,7 +57,7 @@ export default {
|
|||
labelTaskService: LabelTaskService,
|
||||
listIdForNewTask: undefined,
|
||||
validListIdAvailable: false,
|
||||
};
|
||||
}
|
||||
},
|
||||
components: {},
|
||||
props: {
|
||||
|
@ -67,68 +67,68 @@ export default {
|
|||
},
|
||||
},
|
||||
created() {
|
||||
this.listService = new ListService();
|
||||
this.taskService = new TaskService();
|
||||
this.labelService = new LabelService();
|
||||
this.labelTaskService = new LabelTaskService();
|
||||
this.listService = new ListService()
|
||||
this.taskService = new TaskService()
|
||||
this.labelService = new LabelService()
|
||||
this.labelTaskService = new LabelTaskService()
|
||||
},
|
||||
beforeMount() {
|
||||
console.log(this.listId);
|
||||
console.log(this.listId)
|
||||
if (this.listId !== undefined) {
|
||||
this.listIdForNewTask = this.listId;
|
||||
this.validListIdAvailable = true;
|
||||
this.listIdForNewTask = this.listId
|
||||
this.validListIdAvailable = true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addTask() {
|
||||
if (this.newTaskText === '') {
|
||||
this.showError = true;
|
||||
return;
|
||||
this.showError = true
|
||||
return
|
||||
}
|
||||
this.showError = false;
|
||||
this.showError = false
|
||||
|
||||
const task = new TaskModel({
|
||||
title: this.newTaskText,
|
||||
listId: this.listIdForNewTask,
|
||||
});
|
||||
})
|
||||
|
||||
this.taskService
|
||||
.create(task)
|
||||
.then(task => {
|
||||
this.newTaskText = '';
|
||||
this.newTaskText = ''
|
||||
|
||||
// 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 ~
|
||||
if (parts.length > 1) {
|
||||
// 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
|
||||
let labelAddings = [];
|
||||
let labelAddsToWaitFor = [];
|
||||
let labelAddings = []
|
||||
let labelAddsToWaitFor = []
|
||||
parts.forEach((p, index) => {
|
||||
if (index < 1) {
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
labelAddsToWaitFor.push(
|
||||
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
|
||||
parts.forEach((p, index) => {
|
||||
if (index < 1) {
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
// The part up until the next space
|
||||
const labelTitle = p.split(' ')[0];
|
||||
const labelTitle = p.split(' ')[0]
|
||||
|
||||
// Don't create an empty label
|
||||
if (labelTitle === '') {
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
// Check if the label exists
|
||||
|
@ -140,58 +140,58 @@ export default {
|
|||
const labelTask = new LabelTask({
|
||||
taskId: task.id,
|
||||
labelId: res[0].id,
|
||||
});
|
||||
})
|
||||
this.labelTaskService
|
||||
.create(labelTask)
|
||||
.then(result => {
|
||||
task.labels.push(res[0]);
|
||||
task.labels.push(res[0])
|
||||
|
||||
// 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)
|
||||
labelAddings[index - 1].resolve(result);
|
||||
labelAddings[index - 1].resolve(result)
|
||||
})
|
||||
.catch(e => {
|
||||
this.error(e, this);
|
||||
});
|
||||
this.error(e, this)
|
||||
})
|
||||
} else {
|
||||
// label not found, create it
|
||||
const label = new LabelModel({ title: labelTitle });
|
||||
const label = new LabelModel({ title: labelTitle })
|
||||
this.labelService
|
||||
.create(label)
|
||||
.then(res => {
|
||||
const labelTask = new LabelTask({
|
||||
taskId: task.id,
|
||||
labelId: res.id,
|
||||
});
|
||||
})
|
||||
this.labelTaskService
|
||||
.create(labelTask)
|
||||
.then(result => {
|
||||
task.labels.push(res);
|
||||
task.labels.push(res)
|
||||
|
||||
// Remove the label text from the task title
|
||||
task.title = task.title.replace(
|
||||
` ~${labelTitle}`,
|
||||
'',
|
||||
);
|
||||
)
|
||||
|
||||
// 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 => {
|
||||
this.error(e, this);
|
||||
});
|
||||
this.error(e, this)
|
||||
})
|
||||
})
|
||||
.catch(e => {
|
||||
this.error(e, this);
|
||||
});
|
||||
this.error(e, this)
|
||||
})
|
||||
}
|
||||
})
|
||||
.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
|
||||
// been modified to remove each label text
|
||||
|
@ -199,19 +199,19 @@ export default {
|
|||
this.taskService
|
||||
.update(task)
|
||||
.then(() => {
|
||||
this.$store.commit(HAS_TASKS, true);
|
||||
this.$store.commit(HAS_TASKS, true)
|
||||
})
|
||||
.catch(e => {
|
||||
this.error(e, this);
|
||||
});
|
||||
});
|
||||
this.error(e, this)
|
||||
})
|
||||
})
|
||||
}
|
||||
this.$emit('taskAdded', task);
|
||||
this.$emit('taskAdded', task)
|
||||
})
|
||||
.catch(e => {
|
||||
this.error(e, this);
|
||||
});
|
||||
this.error(e, this)
|
||||
})
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -34,9 +34,9 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from 'vuex';
|
||||
import ShowTasks from './tasks/ShowTasks';
|
||||
import AddTask from '../components/tasks/add-task';
|
||||
import { mapState } from 'vuex'
|
||||
import ShowTasks from './tasks/ShowTasks'
|
||||
import AddTask from '../components/tasks/add-task'
|
||||
|
||||
export default {
|
||||
name: 'Home',
|
||||
|
@ -51,7 +51,7 @@ export default {
|
|||
tasks: [],
|
||||
defaultListId: undefined,
|
||||
showTasksKey: 0,
|
||||
};
|
||||
}
|
||||
},
|
||||
created() {
|
||||
//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,
|
||||
defaultNamespaceId: state => {
|
||||
if (state.namespaces.namespaces.length === 0) {
|
||||
return 0;
|
||||
return 0
|
||||
}
|
||||
|
||||
return state.namespaces.namespaces[0].id;
|
||||
return state.namespaces.namespaces[0].id
|
||||
},
|
||||
hasLists: state => {
|
||||
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: {
|
||||
updateTaskList() {
|
||||
this.showTasksKey += 1;
|
||||
this.showTasksKey += 1
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -165,21 +165,21 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import TaskService from '../../../services/task';
|
||||
import TaskModel from '../../../models/task';
|
||||
import LabelTaskService from '../../../services/labelTask';
|
||||
import LabelService from '../../../services/label';
|
||||
import TaskService from '../../../services/task'
|
||||
import TaskModel from '../../../models/task'
|
||||
import LabelTaskService from '../../../services/labelTask'
|
||||
import LabelService from '../../../services/label'
|
||||
|
||||
import EditTask from '../../../components/tasks/edit-task';
|
||||
import AddTask from '../../../components/tasks/add-task';
|
||||
import SingleTaskInList from '../../../components/tasks/partials/singleTaskInList';
|
||||
import taskList from '../../../components/tasks/mixins/taskList';
|
||||
import { saveListView } from '@/helpers/saveListView';
|
||||
import Rights from '../../../models/rights.json';
|
||||
import { mapState } from 'vuex';
|
||||
import FilterPopup from '@/components/list/partials/filter-popup';
|
||||
import { HAS_TASKS } from '@/store/mutation-types';
|
||||
import Nothing from '@/components/misc/nothing';
|
||||
import EditTask from '../../../components/tasks/edit-task'
|
||||
import AddTask from '../../../components/tasks/add-task'
|
||||
import SingleTaskInList from '../../../components/tasks/partials/singleTaskInList'
|
||||
import taskList from '../../../components/tasks/mixins/taskList'
|
||||
import { saveListView } from '@/helpers/saveListView'
|
||||
import Rights from '../../../models/rights.json'
|
||||
import { mapState } from 'vuex'
|
||||
import FilterPopup from '@/components/list/partials/filter-popup'
|
||||
import { HAS_TASKS } from '@/store/mutation-types'
|
||||
import Nothing from '@/components/misc/nothing'
|
||||
|
||||
export default {
|
||||
name: 'List',
|
||||
|
@ -195,7 +195,7 @@ export default {
|
|||
labelService: LabelService,
|
||||
|
||||
ctaVisible: false,
|
||||
};
|
||||
}
|
||||
},
|
||||
mixins: [taskList],
|
||||
components: {
|
||||
|
@ -206,56 +206,56 @@ export default {
|
|||
AddTask,
|
||||
},
|
||||
created() {
|
||||
this.taskService = new TaskService();
|
||||
this.labelService = new LabelService();
|
||||
this.labelTaskService = new LabelTaskService();
|
||||
this.taskService = new TaskService()
|
||||
this.labelService = new LabelService()
|
||||
this.labelTaskService = new LabelTaskService()
|
||||
|
||||
// Save the current list view to local storage
|
||||
// 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({
|
||||
canWrite: state => state.currentList.maxRight > Rights.READ,
|
||||
list: state => state.currentList,
|
||||
}),
|
||||
mounted() {
|
||||
this.$nextTick(() => (this.ctaVisible = true));
|
||||
this.$nextTick(() => (this.ctaVisible = true))
|
||||
},
|
||||
methods: {
|
||||
// This function initializes the tasks page and loads the first page of tasks
|
||||
initTasks(page, search = '') {
|
||||
this.taskEditTask = null;
|
||||
this.isTaskEdit = false;
|
||||
this.loadTasks(page, search);
|
||||
this.taskEditTask = null
|
||||
this.isTaskEdit = false
|
||||
this.loadTasks(page, search)
|
||||
},
|
||||
updateTaskList(task) {
|
||||
this.tasks.push(task);
|
||||
this.sortTasks();
|
||||
this.$store.commit(HAS_TASKS, true);
|
||||
this.tasks.push(task)
|
||||
this.sortTasks()
|
||||
this.$store.commit(HAS_TASKS, true)
|
||||
},
|
||||
editTask(id) {
|
||||
// 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
|
||||
this.taskEditTask = theTask;
|
||||
this.isTaskEdit = true;
|
||||
let theTask = this.getTaskById(id) // Somehow this does not work if we directly assign this to this.taskEditTask
|
||||
this.taskEditTask = theTask
|
||||
this.isTaskEdit = true
|
||||
},
|
||||
getTaskById(id) {
|
||||
for (const t in this.tasks) {
|
||||
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) {
|
||||
for (const t in this.tasks) {
|
||||
if (this.tasks[t].id === updatedTask.id) {
|
||||
this.$set(this.tasks, t, updatedTask);
|
||||
break;
|
||||
this.$set(this.tasks, t, updatedTask)
|
||||
break
|
||||
}
|
||||
}
|
||||
this.sortTasks();
|
||||
this.sortTasks()
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue