3pm-timesheet-module 中文文档教程

发布于 3年前 浏览 22 更新于 3年前

NPM

3PM Packages

Following included packages:
  • Timesheet Package
  • Leave Request Package
Please refer to the wiki for the following:

添加用于批准时间表的复选框

添加 API成功和错误记录

Timesheet Module

Installation

$ npm install 3pm-timesheet-module

如果您还没有设置一个快速服务器,您还需要这样做。

$ npm install express cors nodemon

Features

  • Sign in / Sign out
  • Start new jobs when signing out
  • Selecting multiple assets to assign hours too hasMultiAssets should be set to TRUE() in app.
  • Selecting one asset. hasOneAsset should be set to TRUE() in mobile app.

Usage

这是一个关于如何设置服务器和实施 Timesheet 模块的基本示例。

const express = require('express');
const cors = require('cors');
const { Timesheet } = require('3pm-timesheet-module');

const { knack } = require('./api') // Knack API functions

const app = express();
const PORT = process.env.PORT || 8000;

app.use(cors());
app.use(express.urlencoded({ extended: false }));
app.use(express.json());

app.post('/api/timesheet', async (req, res) => {
  const payload = req.body.Entry;

  const {
    createRecord,
    updateRecord,
    getAllRecords
  } = knack; // API functions
  try {
    const fieldLookup = {
      timesheetID: "field_9",
      signinDateTime: "field_5",
      signoutDateTime: "field_10",
      staffConnection: "field_6",
      staffName: "field_16",
      jobConnection: "field_7",
      signinLocation: "field_8",
      signoutLocation: "field_11",
      lunch: "field_14",
      comments: "field_13",
    };

    await Timesheet(payload, fieldLookup, createRecord, updateRecord, getAllRecords);

    res.status(200).send('Successfully created/updated timesheet entry.');
  } catch(err) {
    res.status(400).json({
      message: 'Failed creating/updating timesheet.',
      error: err
    })
  }
})

Timesheet Props

PropDescriptionTypeRequired
payloadData payload from appobjectYes
lookupObject to map keys / fields{key: field}Yes
createRecordFunction to create timesheet recordfn(obj_num, data, retry?)Yes
updateRecordFunction to update timesheet recordfn(obj_num, data, id, retry?)Yes
getAllRecordsFunction to get record by timesheet IDfn(obj_num, filer?, retry?)Yes
objectNumKnack object # for where payload is going toonumberYes
assetObjectFunction to get record by timesheet IDnumberNo

Leave Request Module

这是一个关于我们如何实施休假流程的基本示例。

app.post('/api/leave', async (req, res) => {
  const { createRecord } = knack;
  try {
    res.status(200).send('Successfully created leave entry.')
    const fieldLookup = {
      firstDay: "field_21",
      lastDay: "field_22",
      days: "field_23",
      staffConnection: "field_18",
      leaveType: "field_19",
      otherLeaveType: "field_20",
      leaveComments: "field_25",
    }
    const objectNum = 4;
    await Leave(req.body.Entry, fieldLookup, createRecord, objectNum)
  } catch (err) {
    res.status(400).json({
      message: 'Failed creating leave request.',
      error: err
    })
  }
})

Leave Props

PropDescriptionTypeRequired
payloadData payload from appobjectYes
lookupObject to map keys / fields{key: field}Yes
createRecordFunction to create leave recordfn(obj_num, data, retry?)Yes
objectNumObject to create records innumberYes

Changelog

对于每个主要或次要版本的变更日志/迁移指南都将在 releases 中提供

NPM

3PM Packages

Following included packages:
  • Timesheet Package
  • Leave Request Package
Please refer to the wiki for the following:

Adding checkboxes for approving timesheets

Adding API success and error logging

Timesheet Module

Installation

$ npm install 3pm-timesheet-module

You will also need to setup an express server if you haven't done so.

$ npm install express cors nodemon

Features

  • Sign in / Sign out
  • Start new jobs when signing out
  • Selecting multiple assets to assign hours too hasMultiAssets should be set to TRUE() in app.
  • Selecting one asset. hasOneAsset should be set to TRUE() in mobile app.

Usage

This is a basic example on how we can setup our server and implement the Timesheet module.

const express = require('express');
const cors = require('cors');
const { Timesheet } = require('3pm-timesheet-module');

const { knack } = require('./api') // Knack API functions

const app = express();
const PORT = process.env.PORT || 8000;

app.use(cors());
app.use(express.urlencoded({ extended: false }));
app.use(express.json());

app.post('/api/timesheet', async (req, res) => {
  const payload = req.body.Entry;

  const {
    createRecord,
    updateRecord,
    getAllRecords
  } = knack; // API functions
  try {
    const fieldLookup = {
      timesheetID: "field_9",
      signinDateTime: "field_5",
      signoutDateTime: "field_10",
      staffConnection: "field_6",
      staffName: "field_16",
      jobConnection: "field_7",
      signinLocation: "field_8",
      signoutLocation: "field_11",
      lunch: "field_14",
      comments: "field_13",
    };

    await Timesheet(payload, fieldLookup, createRecord, updateRecord, getAllRecords);

    res.status(200).send('Successfully created/updated timesheet entry.');
  } catch(err) {
    res.status(400).json({
      message: 'Failed creating/updating timesheet.',
      error: err
    })
  }
})

???? Timesheet Props

PropDescriptionTypeRequired
payloadData payload from appobjectYes
lookupObject to map keys / fields{key: field}Yes
createRecordFunction to create timesheet recordfn(obj_num, data, retry?)Yes
updateRecordFunction to update timesheet recordfn(obj_num, data, id, retry?)Yes
getAllRecordsFunction to get record by timesheet IDfn(obj_num, filer?, retry?)Yes
objectNumKnack object # for where payload is going toonumberYes
assetObjectFunction to get record by timesheet IDnumberNo

Leave Request Module

Here is a basic example on how we could implement the leave process.

app.post('/api/leave', async (req, res) => {
  const { createRecord } = knack;
  try {
    res.status(200).send('Successfully created leave entry.')
    const fieldLookup = {
      firstDay: "field_21",
      lastDay: "field_22",
      days: "field_23",
      staffConnection: "field_18",
      leaveType: "field_19",
      otherLeaveType: "field_20",
      leaveComments: "field_25",
    }
    const objectNum = 4;
    await Leave(req.body.Entry, fieldLookup, createRecord, objectNum)
  } catch (err) {
    res.status(400).json({
      message: 'Failed creating leave request.',
      error: err
    })
  }
})

???? Leave Props

PropDescriptionTypeRequired
payloadData payload from appobjectYes
lookupObject to map keys / fields{key: field}Yes
createRecordFunction to create leave recordfn(obj_num, data, retry?)Yes
objectNumObject to create records innumberYes

???? Changelog

For every major or minor release changelog/migration-guide will be available in releases

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文