Skip to content

Commit

Permalink
Merge branch 'release/0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
lykmapipo committed Jun 4, 2020
2 parents dd0fdcc + 558f1cf commit 22914b7
Show file tree
Hide file tree
Showing 10 changed files with 290 additions and 167 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
#### 0.2.0 (2020-06-04)

##### Chores

* **deps:** force latest version & audit fix ([0737d7b1](https://github.com/codetanzania/ewea-case/commit/0737d7b14230186b3610ba4a1268504850ef9317))

##### New Features

* **model:** add victim nationality ([87be7c58](https://github.com/codetanzania/ewea-case/commit/87be7c58c28f901aabf733ad3b064fb8efabad91))

##### Refactors

* **model:** add gender, occupation & nationality defaults ([7ac45896](https://github.com/codetanzania/ewea-case/commit/7ac458964c801c8a2cd0d670660f3fdd026edc50))

#### 0.1.0 (2020-06-02)

##### New Features
Expand Down
61 changes: 54 additions & 7 deletions es/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { COLLECTION_NAME_CASE, POPULATION_MAX_DEPTH, MODEL_NAME_CASE } from '@codetanzania/ewea-internals';
import { COLLECTION_NAME_CASE, POPULATION_MAX_DEPTH, PREDEFINE_NAMESPACE_ADMINISTRATIVEAREA, PREDEFINE_NAMESPACE_PARTYGENDER, PREDEFINE_NAMESPACE_PARTYOCCUPATION, PREDEFINE_NAMESPACE_PARTYNATIONALITY, MODEL_NAME_CASE } from '@codetanzania/ewea-internals';
import { compact, mergeObjects, idOf, pkg } from '@lykmapipo/common';
import { getString, apiVersion as apiVersion$1 } from '@lykmapipo/env';
import { ObjectId, createSubSchema, model, createSchema, copyInstance, connect } from '@lykmapipo/mongoose-common';
Expand All @@ -12,6 +12,7 @@ import exportable from '@lykmapipo/mongoose-exportable';
import moment from 'moment';
import { Predefine } from '@lykmapipo/predefine';
import { Event } from '@codetanzania/ewea-event';
import { DEFAULT_SEEDS } from '@codetanzania/ewea-common';
import 'mongoose-geojson-schemas';
import { Party } from '@codetanzania/emis-stakeholder';

Expand Down Expand Up @@ -565,6 +566,7 @@ const area = {
order: 3,
default: 'NA',
},
default: DEFAULT_SEEDS[PREDEFINE_NAMESPACE_ADMINISTRATIVEAREA],
};

/**
Expand Down Expand Up @@ -618,7 +620,7 @@ const facility = {
* @property {boolean} taggable - allow field use for tagging
* @property {boolean} default - default value set when none provided
*
* @since 2.6.0
* @since 0.1.0
* @version 0.1.0
* @instance
* @example
Expand All @@ -642,7 +644,7 @@ const gender = {
order: 2,
default: 'NA',
},
default: undefined,
default: DEFAULT_SEEDS[PREDEFINE_NAMESPACE_PARTYGENDER],
};

/**
Expand All @@ -658,7 +660,7 @@ const gender = {
* @property {boolean} taggable - allow field use for tagging
* @property {boolean} default - default value set when none provided
*
* @since 2.6.0
* @since 0.1.0
* @version 0.1.0
* @instance
* @example
Expand All @@ -682,7 +684,47 @@ const occupation = {
order: 2,
default: 'NA',
},
default: undefined,
default: DEFAULT_SEEDS[PREDEFINE_NAMESPACE_PARTYOCCUPATION],
};

/**
* @name nationality
* @description Assignable or given nationality to a party.
*
* @type {object}
* @property {object} type - schema(data) type
* @property {string} ref - referenced collection
* @property {boolean} index - ensure database index
* @property {boolean} exists - ensure ref exists before save
* @property {object} autopopulate - population options
* @property {boolean} taggable - allow field use for tagging
* @property {boolean} default - default value set when none provided
*
* @since 0.2.0
* @version 0.1.0
* @instance
* @example
* {
* "name": { "en" : "Tanzanian" }
* }
*/
const nationality = {
type: ObjectId,
ref: Predefine.MODEL_NAME,
index: true,
exists: true,
aggregatable: { unwind: true },
autopopulate: AUTOPOPULATE_OPTION_PREDEFINE,
taggable: true,
exportable: {
header: 'Nationality',
format: (v) => {
return v && v.strings && compact([v.strings.name.en]).join(' - ');
},
order: 2,
default: 'NA',
},
default: DEFAULT_SEEDS[PREDEFINE_NAMESPACE_PARTYNATIONALITY],
};

/**
Expand Down Expand Up @@ -724,11 +766,13 @@ const nextOfKin = createSubSchema({
* @property {object} gender - Gender of the victim
* @property {number} age - Age of the victim
* @property {number} weight - Weight of the victim
* @property {object} occupation - Occupation of the victim
* @property {object} nationality - Nationality of the victim
* @property {string} address - Address of the victim
*
* @author lally elias <lallyelias87@gmail.com>
* @since 0.1.0
* @version 0.1.0
* @version 0.2.0
* @instance
* @example
* {
Expand All @@ -739,6 +783,8 @@ const nextOfKin = createSubSchema({
* gender: { name: { en: "Female"} },
* age: 23,
* weight: 53,
* occupation: { name: { en: "Businessman"} },
* nationality: { name: { en: "Tanzanian"} },
* address: "Tandale",
* area: { name: { en: "Dar es Salaam"} },
* nextOfKin: { name: "Halima Mdoe", mobile: "+255715463740" }
Expand All @@ -750,10 +796,11 @@ const victim = createSubSchema({
name,
mobile,
gender,
occupation,
age,
// dob
weight,
occupation,
nationality,
address,
area,
nextOfKin,
Expand Down
59 changes: 53 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const exportable = require('@lykmapipo/mongoose-exportable');
const moment = require('moment');
const predefine = require('@lykmapipo/predefine');
const eweaEvent = require('@codetanzania/ewea-event');
const eweaCommon = require('@codetanzania/ewea-common');
require('mongoose-geojson-schemas');
const emisStakeholder = require('@codetanzania/emis-stakeholder');

Expand Down Expand Up @@ -567,6 +568,7 @@ const area = {
order: 3,
default: 'NA',
},
default: eweaCommon.DEFAULT_SEEDS[eweaInternals.PREDEFINE_NAMESPACE_ADMINISTRATIVEAREA],
};

/**
Expand Down Expand Up @@ -620,7 +622,7 @@ const facility = {
* @property {boolean} taggable - allow field use for tagging
* @property {boolean} default - default value set when none provided
*
* @since 2.6.0
* @since 0.1.0
* @version 0.1.0
* @instance
* @example
Expand All @@ -644,7 +646,7 @@ const gender = {
order: 2,
default: 'NA',
},
default: undefined,
default: eweaCommon.DEFAULT_SEEDS[eweaInternals.PREDEFINE_NAMESPACE_PARTYGENDER],
};

/**
Expand All @@ -660,7 +662,7 @@ const gender = {
* @property {boolean} taggable - allow field use for tagging
* @property {boolean} default - default value set when none provided
*
* @since 2.6.0
* @since 0.1.0
* @version 0.1.0
* @instance
* @example
Expand All @@ -684,7 +686,47 @@ const occupation = {
order: 2,
default: 'NA',
},
default: undefined,
default: eweaCommon.DEFAULT_SEEDS[eweaInternals.PREDEFINE_NAMESPACE_PARTYOCCUPATION],
};

/**
* @name nationality
* @description Assignable or given nationality to a party.
*
* @type {object}
* @property {object} type - schema(data) type
* @property {string} ref - referenced collection
* @property {boolean} index - ensure database index
* @property {boolean} exists - ensure ref exists before save
* @property {object} autopopulate - population options
* @property {boolean} taggable - allow field use for tagging
* @property {boolean} default - default value set when none provided
*
* @since 0.2.0
* @version 0.1.0
* @instance
* @example
* {
* "name": { "en" : "Tanzanian" }
* }
*/
const nationality = {
type: mongooseCommon.ObjectId,
ref: predefine.Predefine.MODEL_NAME,
index: true,
exists: true,
aggregatable: { unwind: true },
autopopulate: AUTOPOPULATE_OPTION_PREDEFINE,
taggable: true,
exportable: {
header: 'Nationality',
format: (v) => {
return v && v.strings && common.compact([v.strings.name.en]).join(' - ');
},
order: 2,
default: 'NA',
},
default: eweaCommon.DEFAULT_SEEDS[eweaInternals.PREDEFINE_NAMESPACE_PARTYNATIONALITY],
};

/**
Expand Down Expand Up @@ -726,11 +768,13 @@ const nextOfKin = mongooseCommon.createSubSchema({
* @property {object} gender - Gender of the victim
* @property {number} age - Age of the victim
* @property {number} weight - Weight of the victim
* @property {object} occupation - Occupation of the victim
* @property {object} nationality - Nationality of the victim
* @property {string} address - Address of the victim
*
* @author lally elias <lallyelias87@gmail.com>
* @since 0.1.0
* @version 0.1.0
* @version 0.2.0
* @instance
* @example
* {
Expand All @@ -741,6 +785,8 @@ const nextOfKin = mongooseCommon.createSubSchema({
* gender: { name: { en: "Female"} },
* age: 23,
* weight: 53,
* occupation: { name: { en: "Businessman"} },
* nationality: { name: { en: "Tanzanian"} },
* address: "Tandale",
* area: { name: { en: "Dar es Salaam"} },
* nextOfKin: { name: "Halima Mdoe", mobile: "+255715463740" }
Expand All @@ -752,10 +798,11 @@ const victim = mongooseCommon.createSubSchema({
name,
mobile,
gender,
occupation,
age,
// dob
weight,
occupation,
nationality,
address,
area,
nextOfKin,
Expand Down
Loading

0 comments on commit 22914b7

Please sign in to comment.