Răsfoiți Sursa

Staffing tables

Alan Colon 7 ani în urmă
părinte
comite
3ba1ceac5a

+ 3 - 1
app/assets/index.js

@@ -1,4 +1,6 @@
 const assets = require('material-framework/app/assets')
 module.exports = Object.assign(assets, {
-  logo: require('./logo-simple.png')
+  logo: require('./logo-simple.png'),
+  staffingAgencyIcon: require('@alancnet/icomoon-svg/office.svg'),
+  staffMemberIcon: require('@alancnet/icomoon-svg/user-tie.svg')
 })

+ 3 - 1
app/components/index.js

@@ -1,2 +1,4 @@
 require('./user-area-nav')
-require('./dashboard-page')
+require('./dashboard-page')
+require('./staff-member-pages')
+require('./staffing-agencies-pages')

+ 29 - 0
app/components/staff-member-pages.js

@@ -0,0 +1,29 @@
+const { pages } = require('material-framework/app/crud')
+
+pages({
+  camelName: 'staffMember',
+  columns: [
+    { camelName: 'name', row: 1 },
+    { camelName: 'title', row: 2 },
+    {
+      titleName: 'Staffing Agency',
+      camelName: 'staffingAgencyId',
+      type: 'autocomplete',
+      apiPrefix: '/api/staffing-agencies'
+    }
+  ],
+  layout: [
+    {
+      section: null,
+      rows: [
+        [ 'name', 'title' ]
+      ]
+    },
+    {
+      section: 'Staffing information',
+      rows: [
+        [ 'staffingAgencyId' ]
+      ]
+    }
+  ]
+})

+ 8 - 0
app/components/staffing-agencies-pages.js

@@ -0,0 +1,8 @@
+const { pages } = require('material-framework/app/crud')
+
+pages({
+  camelName: 'staffingAgency',
+  columns: [
+    { camelName: 'name' }
+  ]
+})

+ 16 - 1
app/components/user-area-nav.js

@@ -1,5 +1,5 @@
 const app = require('../app')
-const { dashboardIcon } = require('../assets')
+const { dashboardIcon, staffMemberIcon, staffingAgencyIcon } = require('../assets')
 
 app.component('appUserAreaNav', {
   template: html`
@@ -13,5 +13,20 @@ app.component('appUserAreaNav', {
         Dashboard
       </md-button>
     </md-menu-item>
+
+    <h3>Staff</h3>
+    <md-menu-item>
+      <md-button ng-href="/staff-members">
+        <md-icon md-svg-icon="${staffMemberIcon}"></md-icon>
+        Staff Members
+      </md-button>
+    </md-menu-item>
+    <md-menu-item>
+      <md-button ng-href="/staffing-agencies">
+        <md-icon md-svg-icon="${staffingAgencyIcon}"></md-icon>
+        Staffing Agencies
+      </md-button>
+    </md-menu-item>
+    
   `
 })

+ 1 - 1
app/index.html

@@ -2,7 +2,7 @@
 <html ng-app="app">
 <head>
   <base href="/" />
-  <title>Project App</title>
+  <title>Special Dispatch</title>
   <script type="text/javascript" src="index.js"></script>
 </head>
   <body flex layout="row"><ng-view></ng-view></body>  

+ 2 - 0
app/routes.js

@@ -1,3 +1,5 @@
 module.exports = function($routeProvider) {
   $routeProvider.when('/dashboard', {template: '<app-dashboard-page />'})
+  $routeProvider.crudRoutes({ camelName: 'staffMember' })
+  $routeProvider.crudRoutes({ camelName: 'staffingAgency' })
 }

+ 5 - 1
lib/controllers/index.js

@@ -1,6 +1,10 @@
 const statistics = require('./statistics')
+const staffMember = require('./staff-member')
+const staffingAgency = require('./staffing-agency')
 const { controllers: C } = require('material-framework/server')
 
 module.exports = Object.assign(C, {
-  statistics
+  statistics,
+  staffMember,
+  staffingAgency
 })

+ 6 - 0
lib/controllers/staff-member.js

@@ -0,0 +1,6 @@
+const { controller } = require('material-framework/lib/crud')
+const { StaffMember } = require('../database')
+
+module.exports = controller({
+  Type: StaffMember
+})

+ 6 - 0
lib/controllers/staffing-agency.js

@@ -0,0 +1,6 @@
+const { controller } = require('material-framework/lib/crud')
+const { StaffingAgency } = require('../database')
+
+module.exports = controller({
+  Type: StaffingAgency
+})

+ 7 - 0
lib/database/index.js

@@ -4,6 +4,8 @@ const Location = require('./location')
 const Workday = require('./workday')
 const Service = require('./service')
 const Retailer = require('./retailer')
+const StaffMember = require('./staff-member')
+const StaffingAgency = require('./staffing-agency')
 
 const LocationWorkday = Location.hasMany(Workday)
 const WorkdayLocation = Workday.belongsTo(Location)
@@ -14,12 +16,17 @@ const ServiceWorkday = Service.belongsTo(Workday)
 const RetailerService = Retailer.hasMany(Service)
 const ServiceRetailer = Service.belongsTo(Retailer)
 
+// const StaffingAgencyStaffMember = StaffingAgency.hasMany(StaffMember)
+// const StaffMemberStaffingAgency = StaffMember.belongsTo(StaffingAgency)
+
 
 module.exports = Object.assign(database, {
   Location,
   Workday,
   Service,
   Retailer,
+  StaffMember,
+  StaffingAgency,
   LocationWorkday,
   WorkdayLocation,
   WorkdayService,

+ 25 - 0
lib/database/staff-member.js

@@ -0,0 +1,25 @@
+const Sequelize = require('sequelize')
+const sequelize = require('./sequelize')
+
+const StaffMember = sequelize.define('staffMember', {
+  id: {
+    type: Sequelize.UUID,
+    defaultValue: Sequelize.UUIDV1,
+    primaryKey: true
+  },
+  staffingAgencyId: Sequelize.UUID,
+  name: Sequelize.STRING,
+  title: Sequelize.STRING,
+  identifier: Sequelize.STRING,
+  locationId: Sequelize.UUID
+}, {
+  paranoid: true,
+  indexes: [
+    {
+      unique: true,
+      fields: ['staffingAgencyId', 'identifier']
+    }
+  ]
+})
+
+module.exports = StaffMember

+ 25 - 0
lib/database/staffing-agency.js

@@ -0,0 +1,25 @@
+const Sequelize = require('sequelize')
+const sequelize = require('./sequelize')
+
+const StaffingAgency = sequelize.define('staffingAgency', {
+  id: {
+    type: Sequelize.UUID,
+    defaultValue: Sequelize.UUIDV1,
+    primaryKey: true
+  },
+  name: Sequelize.STRING,
+  key: {
+    type: Sequelize.STRING,
+    unique: true
+  }
+}, {
+  paranoid: true,
+  indexes: [
+    {
+      unique: true,
+      fields: ['key']
+    }
+  ]
+})
+
+module.exports = StaffingAgency

+ 3 - 0
lib/routes.js

@@ -1,4 +1,7 @@
 const C = require('./controllers')
+const { routes:crudRoutes } = require('material-framework/lib/crud')
 module.exports = app => {
   app.get('/api/statistics', C.statistics.get)
+  crudRoutes({ app, controller: C.staffMember, camelName: 'staffMember' })
+  crudRoutes({ app, controller: C.staffingAgency, camelName: 'staffingAgency' })
 }