Skip to content

Commit

Permalink
to revert
Browse files Browse the repository at this point in the history
  • Loading branch information
zqyadam committed Feb 8, 2017
1 parent 7475857 commit 64409a9
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 143 deletions.
12 changes: 12 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,16 @@ body {
width: 100%;
height: 100%;
}
.fit {
width: 100%;
height: 100%;
}
.fitWidth {
width: 100%;
}
.scroll {
overflow: auto;
}
</style>
7 changes: 5 additions & 2 deletions src/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export let SaveTodoItem = function(item) {

export let LoadServerTodos = function() {
var uid = getCurrentUser().id;
var query = new AV.Query('Todo');
return query.equalTo('owner',uid).find();
var ownerQuery = new AV.Query('Todo');
ownerQuery.equalTo('owner',uid);
var enableQuery = new AV.Query('Todo');
enableQuery.equalTo('enable',true);
return AV.Query.and(ownerQuery, enableQuery).find();
}
133 changes: 92 additions & 41 deletions src/components/list.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
<template>
<div>
<mu-list v-if="todoData.length">
<mu-list-item v-for="(todo,index) in todoData" :title="todo.attributes.content" :key="index">
<mu-icon :value="iconType" slot="left" @click="toggleStatus(todo)" />
<mu-icon-button icon="delete" @click="deleteTodo(todo)" v-show="showDeleteBtn" touch slot="right"></mu-icon-button>
<mu-icon-button icon="mode_edit" @click="editTodo(todo)" touch slot="right" :style="{'margin-right':showDeleteBtn?'60px':'0px'}" />
</mu-list-item>
</mu-list>
<div v-else class="no-todo-tip">
还没有<span :class="noTodoTipClass"><span style="font-weight:bold;">{{ !showDeleteBtn?"未完成":"已完成" }}</span>的[{{ types[type] }}]</span>事项,赶紧添加一个吧~
</div>
<div class="fit scroll">
<!-- {{ todos }} -->

<mu-flexbox :gutter="0" justify="center" class="fit" align="stretch" style="border:1px solid blue">
<!-- -->
<v-touch class="fit" style="border:1px solid red" v-on:swipeleft="nextTab" v-on:swiperight="previousTab" v-on:dbltap="addTodoItem">
<mu-list v-if="todoData.length">
<mu-list-item v-for="(todo,index) in todoData" :title="todo.attributes.content" :key="index" >
<mu-icon :value="iconType" slot="left" @click="toggleStatus(todo)" />
<mu-icon-button icon="delete" @click="deleteTodo(todo)" v-show="done" touch slot="right"></mu-icon-button>
<mu-icon-button icon="mode_edit" @click="editTodo(todo)" touch slot="right" :style="{'margin-right':done?'60px':'0px'}" />
<span style="color: #ccc" slot="describe">更新时间:{{ new Date(todo.updatedAt).toLocaleString() }}</span>
</mu-list-item>
</mu-list>
<div v-else class="no-todo-tip">
还没有<span :class="type+'Title'"><span style="font-weight:bold;">{{ !done?"未完成":"已完成" }}</span>的[{{ types[type] }}]</span>事项,赶紧添加一个吧~
</div>
<!-- <z-list v-if="type === 'ImpEmg'" :todos="ImpEmgTodos" type="ImpEmg" noTodoTipClass="ImpEmgTitle" :done="bottomNav" :types="types" />
<z-list v-if="type === 'ImpNotEmg'" :todos="ImpNotEmgTodos" type="ImpNotEmg" noTodoTipClass="ImpNotEmgTitle" :done="bottomNav" :types="types" />
<z-list v-if="type === 'NotImpEmg'" :todos="NotImpEmgTodos" type="NotImpEmg" noTodoTipClass="NotImpEmgTitle" :done="bottomNav" :types="types" />
<z-list v-if="type === 'NotImpNotEmg'" :todos="NotImpNotEmgTodos" type="NotImpNotEmg" noTodoTipClass="NotImpNotEmgTitle" :done="bottomNav" :types="types" /> -->
</v-touch>
</mu-flexbox>
<!-- list end -->
</mu-flexbox>
<!--************************** 不显示内容 ****************************-->
<!-- edit Todo Item dialog -->
<mu-dialog :open="editTodoDialog" title="修改Todo" @close="closeEditTodoDialog">
Expand Down Expand Up @@ -44,17 +58,6 @@ import {
} from '../api/api';
export default {
data: function() {
return {
editTodoDialog: false,
todoTempCopy: {
content: '',
type: '',
status: false
},
todoTemp: null
}
},
props: {
todos: {
type: Array,
Expand All @@ -64,31 +67,35 @@ export default {
type: String,
default: ""
},
noTodoTipClass: {
type: String
},
showDeleteBtn: {
done: {
type: Boolean,
default: false
},
types: {
type: Object
}
},
data: function() {
return {
editTodoDialog: false,
todoTempCopy: {
content: '',
type: '',
status: false
},
todoTemp: null,
doneCount: 0
}
},
computed: {
todoData: function() {
let _this = this;
return this.todos.filter(function(item) {
item = item.toJSON();
return (item.status === _this.showDeleteBtn) && (item.enable);
return (item.attributes.type === _this.type) && (item.attributes.status === _this.done) && (item.attributes.enable);
})
},
fadeDirection: function() {
return this.showDeleteBtn ? 'fade-right' : 'fade-left';
},
iconType: function() {
return this.showDeleteBtn ? 'redo' : 'restore'
return this.done ? 'redo' : 'restore'
},
labelClass: function() {
return this.todoTempCopy.type + 'Title';
Expand All @@ -100,13 +107,13 @@ export default {
item.save();
},
deleteTodo: function(item) {
item.set('enable',false);
item.save();
item.set('enable', false);
item.save();
},
editTodo: function(item) {
var _this = this;
this.todoTemp = item;
item = item.toJSON()
item = item.toJSON();
Object.keys(item).forEach(function(key) {
_this.todoTempCopy[key] = item[key];
})
Expand All @@ -117,14 +124,57 @@ export default {
},
saveTodoChange: function() {
var _this = this;
delete _this.todoTempCopy.objectId;
delete _this.todoTempCopy.createdAt;
delete _this.todoTempCopy.updatedAt;
delete this.todoTempCopy.objectId;
delete this.todoTempCopy.createdAt;
delete this.todoTempCopy.updatedAt;
Object.keys(this.todoTempCopy).forEach(function(key) {
_this.todoTemp.set(key, _this.todoTempCopy[key])
})
_this.todoTemp.save();
this.closeEditTodoDialog();
},
nextTab: function() {
console.log('nextTab');
switch (this.type) {
case "ImpEmg":
this.$emit('typeChange', "ImpNotEmg");
break;
case "ImpNotEmg":
this.$emit('typeChange', "NotImpEmg");
break;
case "NotImpEmg":
this.$emit('typeChange', "NotImpNotEmg");
break;
case "NotImpNotEmg":
this.$emit('typeChange', "ImpEmg");
break;
default:
this.$emit('typeChange', "ImpEmg");
break;
}
},
previousTab: function() {
switch (this.type) {
case "ImpEmg":
this.$emit('typeChange', "NotImpNotEmg");
break;
case "ImpNotEmg":
this.$emit('typeChange', "ImpEmg");
break;
case "NotImpEmg":
this.$emit('typeChange', "ImpNotEmg");
break;
case "NotImpNotEmg":
this.$emit('typeChange', "NotImpEmg");
break;
default:
this.$emit('typeChange', "ImpEmg");
break;
}
},
addTodoItem: function() {
console.log('dbl tap');
this.$emit('addTodoItem');
}
}
}
Expand All @@ -150,7 +200,8 @@ export default {
/* fade transition */
.fade-left-leave-active {
/*.fade-left-leave-active {
transition: all .1s cubic-bezier(1.0, 0.5, 0.8, 1.0);
}
}*/
</style>
16 changes: 9 additions & 7 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Register from './pages/login/register'
import TodoTab from './pages/todo-tab'
import Edit from './pages/edit'
// load api
import { getlocalStorageItemName, isLogedin } from './api/api'
import { isLogedin } from './api/api'
// install plugins
Vue.use(VueRouter);
Vue.use(MuseUI);
Expand Down Expand Up @@ -57,13 +57,15 @@ let router = new VueRouter({
})

router.beforeEach((to, from, next) => {
console.log('from');
console.log(from);
console.log('to');
console.log(to);
if (to.matched.some(record => record.meta.requiresAuth)) {
// let user = JSON.parse(localStorage.getItem(getlocalStorageItemName()));
// if (!user) {
// next({ path: '/login', });
// }
if (!isLogedin) {
next({ path: '/login' });
console.log(isLogedin());
if (!isLogedin()) {
console.log('redirecting to login page');
next({ name: 'login' });
}
}
next();
Expand Down
Loading

0 comments on commit 64409a9

Please sign in to comment.