Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Commit

Permalink
demo 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
harryho committed May 7, 2018
1 parent 2955856 commit 8387eb9
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 32 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue2crm",
"version": "1.7.6",
"name": "vue2crm-demo",
"version": "1.0.0",
"description": "Simle reusalbe CRM starter built on Vue 2 PWA template and Vuetify UI",
"author": "harryho",
"private": true,
Expand Down
5 changes: 0 additions & 5 deletions src/store/modules/customers.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/* globals Store */
// import Vue from "vue";
// import Vuex from "vuex";

// import api from "@/utils/backend-api";
import api from "@/utils/demo-api";
import { Customer } from "@/models";
import {
Expand Down
5 changes: 0 additions & 5 deletions src/store/modules/orders.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/* globals Store */
// import Vue from "vue";
// import Vuex from "vuex";

// import api from "@/utils/backend-api";
import api from "@/utils/demo-api";
import {Order} from "@/models";
import {
Expand Down
2 changes: 0 additions & 2 deletions src/store/modules/products.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import {get} from "lodash"
const state = {
items: [],
pagination: getDefaultPagination(),
// page: 0,
// pages: 0,
loading: false,
mode: "",
snackbar: false,
Expand Down
5 changes: 0 additions & 5 deletions src/store/modules/user.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// import Vue from "vue"
// import Vuex from "vuex"

// Vue.use(Vuex)

const state = {
callingAPI: false,
searching: "",
Expand Down
23 changes: 12 additions & 11 deletions src/utils/demo-api.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import db from "./demo-db"

const ds = ds || Object.assign({}, db)
let ds = ds || Object.assign({}, db)

function getModel (action) {
function getModel(action) {
if (action.includes('?') && action.includes('/')) {
return action.indexOf('?') > action.indexOf('/') ? action.substring(0, action.indexOf('/')) : action.substring(0, action.indexOf('?'))
} else {
return action.includes('?') ? action.substring(0, action.indexOf('?')) : action.substring(0, action.indexOf('/'))
}
}

function getId (action, model) {
function getId(action, model) {
action = action.substr(model.length + 1)
return action.length > 0 && (action.includes('?') ? action.substring(0, action.indexOf('?')) : action)
}

function getExpand (action, model) {
function getExpand(action, model) {
action = action.substr(action.indexOf('?'))
return action.includes('_expand') ? (
action.includes('&') ?
action.substring('_expand='.length + 1, action.indexOf('&')) :
action.substring('_expand='.length + 1)) : undefined
}

function getEmbed (action, model) {
function getEmbed(action, model) {
return action.includes('?') ? action.substring(action.indexOf('/'), action.indexOf('?')) : action.substring(action.indexOf('/'))
}


export default {
getData (action) {
getData(action) {

return new Promise(function (resolve, reject) {
const model = getModel(action)
Expand Down Expand Up @@ -65,33 +65,34 @@ export default {
setTimeout(resolve, 200, { data: result })
});
},
postData (action, data) {
postData(action, data) {
return new Promise(function (resolve, reject) {
const model = getModel(action)
data.id = ds[model] + 1
ds[model].push(data)
setTimeout(resolve, 200, { data: data })
})
},
putData (action, data) {
putData(action, data) {
return new Promise(function (resolve, reject) {
const model = getModel(action)
const idx = ds[model].findIndex(d => d.id === data.id)
ds[model][idx] = Object.assign({}, data)
setTimeout(resolve, 200, { data: data })
})
},
deleteData (action) {
deleteData(action) {
return new Promise(function (resolve, reject) {
const model = getModel(action)
const id = getId()
id && ds[model].splice(ds[model].findIndex(d => d.id === id))
setTimeout(resolve, 200, { status: 200 })
})
},
login (action, data) {
login(action, data) {
ds = ds || Object.assign({}, db)
return new Promise(function (resolve, reject) {
const { access_token , user } = ds.token
const { access_token, user } = ds.token
setTimeout(resolve, 200, {
data: {
access_token,
Expand Down
4 changes: 2 additions & 2 deletions src/utils/store-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function sendErrorNotice (commit, notice) {
}

/**
* Set pagination to the products store
* Set pagination to the store
* @param {*} commit -- commit funciton pass from caller
* @param {*} page -- current page number
* @param {*} totalItems -- total amount of items
Expand Down Expand Up @@ -67,7 +67,7 @@ export function closeNotice (commit, timeout) {


/**
* Set pagination to the products store
* Set pagination to the store
* @param {*} commit -- commit funciton pass from caller
* @param {*} items -- search result
*/
Expand Down

0 comments on commit 8387eb9

Please sign in to comment.