diff --git a/creator/app/apps/hr.coffee b/creator/app/apps/hr.coffee index ca35698391..91731c2fd8 100644 --- a/creator/app/apps/hr.coffee +++ b/creator/app/apps/hr.coffee @@ -2,4 +2,4 @@ Creator.Apps.hr = url: "/creator/hr" name: "HR" icon: "ion-ios-people-outline" - objects: ["flow_roles"] + objects: ["organizations", "flow_roles"] diff --git a/creator/packages/steedos-creator/core.coffee b/creator/packages/steedos-creator/core.coffee index c9dabaa324..4221a5ff97 100644 --- a/creator/packages/steedos-creator/core.coffee +++ b/creator/packages/steedos-creator/core.coffee @@ -94,36 +94,7 @@ Creator.initApps = ()-> Creator.getObjectSchema = (obj) -> - baseFields = - owner: - type: "text", - omit: true - space: - type: "text", - omit: true - created: - type: "datetime", - omit: true - created_by: - type: "text", - omit: true - modified: - type: "datetime", - omit: true - modified_by: - type: "text", - omit: true - last_activity: - type: "datetime", - omit: true - last_viewed: - type: "datetime", - omit: true - last_referenced: - type: "datetime", - omit: true - - _.extend(obj.fields, baseFields) + _.extend(obj.fields, Creator.baseObject.fields) schema = {} _.each obj.fields, (field, field_name)-> @@ -140,14 +111,17 @@ Creator.getObjectSchema = (obj) -> fs.type = "Date" else if field.type == "datetime" fs.type = "Date" - else if field.type == "master_detail" + else if field.type == "lookup" or field.type == "master_detail" fs.type = "String" if Meteor.isClient - fs.autoform.type="universe-select" - fs.autoform.optionsMethod="creator.object_options" - fs.autoform.optionsMethodParams= - reference_to: field.reference_to - space: Session.get("spaceId") + if field.reference_to == "users" + fs.autoform.type = "selectuser" + else + fs.autoform.type="universe-select" + fs.autoform.optionsMethod="creator.object_options" + fs.autoform.optionsMethodParams= + reference_to: field.reference_to + space: Session.get("spaceId") else if field.type == "select" fs.type = "String" fs.autoform.type = "select2" diff --git a/creator/packages/steedos-creator/models/base.coffee b/creator/packages/steedos-creator/models/base.coffee new file mode 100644 index 0000000000..2cb611b9e2 --- /dev/null +++ b/creator/packages/steedos-creator/models/base.coffee @@ -0,0 +1,29 @@ +Creator.baseObject = + fields: + owner: + type: "lookup", + reference_to: "users" + space: + type: "text", + omit: true + created: + type: "datetime", + omit: true + created_by: + type: "text", + omit: true + modified: + type: "datetime", + omit: true + modified_by: + type: "text", + omit: true + last_activity: + type: "datetime", + omit: true + last_viewed: + type: "datetime", + omit: true + last_referenced: + type: "datetime", + omit: true \ No newline at end of file diff --git a/creator/app/objects/Roles.coffee b/creator/packages/steedos-creator/models/flow_role.coffee similarity index 100% rename from creator/app/objects/Roles.coffee rename to creator/packages/steedos-creator/models/flow_role.coffee diff --git a/creator/packages/steedos-creator/models/object.coffee b/creator/packages/steedos-creator/models/object.coffee index 001e57398c..0839f7072f 100644 --- a/creator/packages/steedos-creator/models/object.coffee +++ b/creator/packages/steedos-creator/models/object.coffee @@ -1,61 +1,81 @@ -db.objects = new Mongo.Collection('objects'); +Creator.Objects.objects = + name: "objects" + label: "Objects" + icon: "ion-ios-people-outline" + fields: + name: + label: "Name" + type: "text" + description: + label: "Name" + type: "text" + list_views: + default: + columns: ["name", "description", "modified"] + permissions: + default: + allowCreate: false + allowDelete: false + allowEdit: false + allowRead: true + modifyAllRecords: false + viewAllRecords: false +# db.objects._simpleSchema = new SimpleSchema +# name: +# type: String +# max: 50 +# code: +# type: String +# max: 50 +# description: +# type: String +# optional: true +# max: 50 +# autoform: +# rows: 2 +# schema: +# type: String +# optional: true +# autoform: +# rows: 10 +# created: +# type: Date, +# optional: true +# autoform: +# omit: true +# created_by: +# type: String, +# optional: true +# autoform: +# omit: true +# modified: +# type: Date, +# optional: true +# autoform: +# omit: true +# modified_by: +# type: String, +# optional: true +# autoform: +# omit: true -db.objects._simpleSchema = new SimpleSchema - name: - type: String - max: 50 - code: - type: String - max: 50 - description: - type: String - optional: true - max: 50 - autoform: - rows: 2 - schema: - type: String - optional: true - autoform: - rows: 10 - created: - type: Date, - optional: true - autoform: - omit: true - created_by: - type: String, - optional: true - autoform: - omit: true - modified: - type: Date, - optional: true - autoform: - omit: true - modified_by: - type: String, - optional: true - autoform: - omit: true - -db.objects.attachSchema(db.objects._simpleSchema); +# db.objects.attachSchema(db.objects._simpleSchema); -TabularTables["objects"] = new Tabular.Table - name: "objects", - collection: db.objects, - columns: [ - { data: "name" }, - { data: "code" }, - { data: "description" }, - { data: "modified" } - ] - dom: "tp" - extraFields: ["_id", "space", "schema"] - lengthChange: false - ordering: false - pageLength: 10 - info: false - searching: true - autoWidth: true +# TabularTables["objects"] = new Tabular.Table +# name: "objects", +# collection: db.objects, +# columns: [ +# { data: "name" }, +# { data: "code" }, +# { data: "description" }, +# { data: "modified" } +# ] +# dom: "tp" +# extraFields: ["_id", "space", "schema"] +# lengthChange: false +# ordering: false +# pageLength: 10 +# info: false +# searching: true +# autoWidth: true diff --git a/creator/packages/steedos-creator/models/organization.coffee b/creator/packages/steedos-creator/models/organization.coffee new file mode 100644 index 0000000000..7d2a59e6d1 --- /dev/null +++ b/creator/packages/steedos-creator/models/organization.coffee @@ -0,0 +1,20 @@ +Creator.Objects.organizations = + name: "organizations" + label: "Organizations" + icon: "ion-ios-people-outline" + fields: + name: + label: "Name" + type: "text" + required: true + list_views: + default: + columns: ["name", "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/packages/steedos-creator/models/user.coffee b/creator/packages/steedos-creator/models/user.coffee new file mode 100644 index 0000000000..322b2b0ddf --- /dev/null +++ b/creator/packages/steedos-creator/models/user.coffee @@ -0,0 +1,20 @@ +Creator.Objects.users = + name: "users" + label: "Users" + icon: "ion-ios-people-outline" + fields: + name: + label: "Name" + type: "text" + required: true + list_views: + default: + columns: ["name", "username"] + permissions: + default: + allowCreate: false + allowDelete: false + allowEdit: false + allowRead: true + modifyAllRecords: false + viewAllRecords: false \ No newline at end of file diff --git a/creator/packages/steedos-creator/package.js b/creator/packages/steedos-creator/package.js index 8072402b3e..9a5eb8378d 100644 --- a/creator/packages/steedos-creator/package.js +++ b/creator/packages/steedos-creator/package.js @@ -79,7 +79,12 @@ Package.onUse(function(api) { api.addFiles('core.coffee'); + api.addFiles('models/base.coffee'); api.addFiles('models/object.coffee'); + + api.addFiles('models/organization.coffee'); + api.addFiles('models/user.coffee'); + api.addFiles('models/flow_role.coffee'); api.addFiles('server/methods/object_options.coffee', 'server'); api.addFiles('server/publications/object.coffee', 'server');