From 84737102916276803953b7e055faec250ccd3ed6 Mon Sep 17 00:00:00 2001 From: Jack Zhuang Date: Tue, 12 Dec 2017 18:16:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E6=9D=83=E9=99=90=E6=8E=A7?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- creator/app/objects/Customers.coffee | 11 +++++- creator/client/router.coffee | 4 +- .../steedos-creator/client/router.coffee | 8 ++-- .../steedos-creator/client/views/list.coffee | 13 +++++-- .../steedos-creator/client/views/list.html | 8 ++-- creator/packages/steedos-creator/core.coffee | 37 ++++++++++++++++--- 6 files changed, 61 insertions(+), 20 deletions(-) diff --git a/creator/app/objects/Customers.coffee b/creator/app/objects/Customers.coffee index 0fb77e37f3..47abeb3616 100644 --- a/creator/app/objects/Customers.coffee +++ b/creator/app/objects/Customers.coffee @@ -1,6 +1,7 @@ Creator.Objects.customers = name: "customers" label: "Customers" + icon: "ion-ios-people-outline" schema: name: label: "Name", @@ -14,5 +15,11 @@ Creator.Objects.customers = list_views: default: columns: ["name", "description", "modified"] - - + permissions: + default: + allowCreate: true + allowDelete: true + allowEdit: true + allowRead: true + modifyAllRecords: false + viewAllRecords: false \ No newline at end of file diff --git a/creator/client/router.coffee b/creator/client/router.coffee index 3b6da9393f..92c8d84c23 100644 --- a/creator/client/router.coffee +++ b/creator/client/router.coffee @@ -3,6 +3,8 @@ FlowRouter.route '/', if !Meteor.userId() FlowRouter.go '/steedos/sign-in?redirect=' + context.path; else - Session.set("apps", ["creator"]); FlowRouter.go '/creator' + +Meteor.startup -> + Session.set("apps", ["creator"]); \ No newline at end of file diff --git a/creator/packages/steedos-creator/client/router.coffee b/creator/packages/steedos-creator/client/router.coffee index 8a576c9af7..6f44e1e459 100644 --- a/creator/packages/steedos-creator/client/router.coffee +++ b/creator/packages/steedos-creator/client/router.coffee @@ -5,14 +5,14 @@ checkUserSigned = (context, redirect) -> FlowRouter.route '/creator', triggersEnter: [ checkUserSigned ], action: (params, queryParams)-> - FlowRouter.go "/creator/objects/home" + FlowRouter.go "/creator/crm/customers" -FlowRouter.route '/creator/:collection_name/home', +FlowRouter.route '/creator/:app_id/:object_name', triggersEnter: [ checkUserSigned ], action: (params, queryParams)-> - Meteor.call "creator_object_init", params.collection_name, (error, object)-> + Meteor.call "creator_object_init", params.object_name, (error, object)-> if object - Creator.objectClientInit(params.collection_name, object); + Creator.objectClientInit(params.object_name, object); BlazeLayout.render 'recordLayout', main: "creator_list" diff --git a/creator/packages/steedos-creator/client/views/list.coffee b/creator/packages/steedos-creator/client/views/list.coffee index 60054fd427..dc6449d481 100644 --- a/creator/packages/steedos-creator/client/views/list.coffee +++ b/creator/packages/steedos-creator/client/views/list.coffee @@ -1,17 +1,22 @@ Template.creator_list.helpers collectionName: ()-> - return FlowRouter.getParam("collection_name") + return FlowRouter.getParam("object_name") collection: ()-> - return "Creator.Collections." + FlowRouter.getParam("collection_name") + return "Creator.Collections." + FlowRouter.getParam("object_name") tabular_table: ()-> - return Creator.TabularTables[FlowRouter.getParam("collection_name")] + return Creator.TabularTables[FlowRouter.getParam("object_name")] + + hasPermission: (permissionName)-> + permissions = Creator.Objects[FlowRouter.getParam("object_name")]?.permissions?.default + if permissions + return permissions[permissionName] + Template.creator_list.events 'click .table-creator tr': (event) -> - console.log("table-creator....") dataTable = $(event.target).closest('table').DataTable(); rowData = dataTable.row(event.currentTarget).data() if rowData diff --git a/creator/packages/steedos-creator/client/views/list.html b/creator/packages/steedos-creator/client/views/list.html index 284ba29488..d0701f0afe 100644 --- a/creator/packages/steedos-creator/client/views/list.html +++ b/creator/packages/steedos-creator/client/views/list.html @@ -8,9 +8,11 @@
- {{#afModal class="btn btn-primary creator-add" collection=collection operation="insert" dialogClass="modal-lg modal-body-zoom" buttonContent=insertButtonContent}} - {{_ "Create"}} - {{/afModal}} + {{#if hasPermission "allowCreate"}} + {{#afModal class="btn btn-primary creator-add" collection=collection operation="insert" dialogClass="modal-lg modal-body-zoom" buttonContent=insertButtonContent}} + {{_ "Create"}} + {{/afModal}} + {{/if}}
diff --git a/creator/packages/steedos-creator/core.coffee b/creator/packages/steedos-creator/core.coffee index c36bc9de07..d487196aa5 100644 --- a/creator/packages/steedos-creator/core.coffee +++ b/creator/packages/steedos-creator/core.coffee @@ -21,7 +21,7 @@ Creator.baseSchema = autoform: omit: true modified: - type: Date, + type: "Date", optional: true autoform: omit: true @@ -31,6 +31,23 @@ Creator.baseSchema = autoform: omit: true + last_activity: + type: Date, + optional: true + autoform: + omit: true + last_viewed: + type: Date, + optional: true + autoform: + omit: true + last_referenced: + type: Date, + optional: true + autoform: + omit: true + + Meteor.startup -> _.each Creator.Objects, (obj, collection_name)-> @@ -76,15 +93,23 @@ Meteor.startup -> Creator.getObjectSchema = (obj) -> if obj?.schema - schema = JSON.parse(JSON.stringify(obj.schema)) + schema = obj.schema _.extend(schema, Creator.baseSchema) return schema Creator.getObjectColumns = (obj, list_view) -> cols = [] _.each obj.list_views?[list_view]?.columns, (column_name)-> - col = {} - col.data = column_name - col.title = obj.schema[column_name]?.label - cols.push(col) + if obj.schema[column_name]?.type + col = {} + col.title = obj.schema[column_name]?.label + col.data = column_name + col.render = (val, type, doc) -> + if (val instanceof Date) + return moment(val).format('YYYY-MM-DD H:mm') + else if (val == null) + return "" + else + return val; + cols.push(col) return cols