| Total Complexity | 10 |
| Complexity/F | 10 |
| Lines of Code | 31 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | import extend from 'extend' |
||
| 2 | import { |
||
| 3 | cmsData |
||
| 4 | ,config |
||
| 5 | ,dateSlug |
||
| 6 | } from '../../' |
||
| 7 | |||
| 8 | export function add(tpl, json, type, obj = {}, date = null, realType = 'draft') { |
||
| 9 | let meta = config.meta.name |
||
| 10 | |||
| 11 | // json[meta] = extend({}, json[meta]) |
||
| 12 | var currentDate = (typeof date !== 'undefined' && date !== null && date !== '') ? date : new Date() |
||
| 13 | var abeUrl = (type === 'publish') ? json[meta].link : cmsData.fileAttr.add(json[meta].link, 'd' + dateSlug(currentDate.toISOString())) + '' |
||
| 14 | |||
| 15 | if(typeof json[meta].date === 'undefined' || json[meta].date === null) { |
||
| 16 | json[meta].date = currentDate |
||
| 17 | } |
||
| 18 | json[meta].latest = { |
||
| 19 | date: currentDate, |
||
| 20 | abeUrl: abeUrl |
||
| 21 | } |
||
| 22 | json[meta].status = realType === 'reject' ? 'draft' : realType |
||
| 23 | if(typeof json[meta][type] === 'undefined' || json[meta][type] === null) { |
||
| 24 | json[meta][type] = JSON.parse(JSON.stringify(obj)) |
||
| 25 | json[meta][type].date = currentDate |
||
| 26 | json[meta][type].abeUrl = abeUrl |
||
| 27 | } |
||
| 28 | json[meta][type].latest = JSON.parse(JSON.stringify(obj)) |
||
| 29 | json[meta][type].latest.date = currentDate |
||
| 30 | json[meta][type].latest.abeUrl = abeUrl |
||
| 31 | } |