Skip to content

Commit 4ceb914

Browse files
authored
Merge pull request #275 from performant-software/feature/cdc27_events
CDC #27 - Events
2 parents 1225737 + 6368c7a commit 4ceb914

File tree

12 files changed

+133
-14
lines changed

12 files changed

+133
-14
lines changed

packages/controlled-vocabulary/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/controlled-vocabulary",
3-
"version": "2.1.2",
3+
"version": "2.1.3",
44
"description": "A package of components to allow user to configure dropdown elements. Use with the \"controlled_vocabulary\" gem.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",
@@ -23,8 +23,8 @@
2323
"underscore": "^1.13.2"
2424
},
2525
"peerDependencies": {
26-
"@performant-software/semantic-components": "^2.1.2",
27-
"@performant-software/shared-components": "^2.1.2",
26+
"@performant-software/semantic-components": "^2.1.3",
27+
"@performant-software/shared-components": "^2.1.3",
2828
"react": ">= 16.13.1 < 19.0.0",
2929
"react-dom": ">= 16.13.1 < 19.0.0"
3030
},

packages/core-data/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/core-data",
3-
"version": "2.1.2",
3+
"version": "2.1.3",
44
"description": "A package of components used with the Core Data platform.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",
@@ -38,7 +38,7 @@
3838
"underscore": "^1.13.2"
3939
},
4040
"peerDependencies": {
41-
"@performant-software/geospatial": "^2.1.2",
41+
"@performant-software/geospatial": "^2.1.3",
4242
"@peripleo/maplibre": "^0.5.2",
4343
"@peripleo/peripleo": "^0.5.2",
4444
"react": ">= 16.13.1 < 19.0.0",

packages/geospatial/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/geospatial",
3-
"version": "2.1.2",
3+
"version": "2.1.3",
44
"description": "A package of components for all things map-related.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",

packages/semantic-ui/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/semantic-components",
3-
"version": "2.1.2",
3+
"version": "2.1.3",
44
"description": "A package of shared components based on the Semantic UI Framework.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",
@@ -35,7 +35,7 @@
3535
"zotero-translation-client": "^5.0.1"
3636
},
3737
"peerDependencies": {
38-
"@performant-software/shared-components": "^2.1.2",
38+
"@performant-software/shared-components": "^2.1.3",
3939
"@samvera/clover-iiif": "^2.3.2",
4040
"react": ">= 16.13.1 < 19.0.0",
4141
"react-dnd": "^11.1.3",

packages/semantic-ui/src/components/FuzzyDate.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type DateComponent = {
4141

4242
type Props = {
4343
calendar?: string,
44+
centered?: boolean,
4445
date: DateInput,
4546
description?: boolean,
4647
locale?: string,
@@ -339,6 +340,7 @@ class FuzzyDate extends Component<Props, State> {
339340
{ (mountNode) => (
340341
<Modal
341342
as={Form}
343+
centered={this.props.centered}
342344
className='fuzzy-date-modal'
343345
mountNode={mountNode}
344346
open={this.state.modal}

packages/shared/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/shared-components",
3-
"version": "2.1.2",
3+
"version": "2.1.3",
44
"description": "A package of shared, framework agnostic, components.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",

packages/shared/src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export { default as BaseService } from './services/BaseService';
2323
export { default as Attachments } from './transforms/Attachments';
2424
export { default as BaseTransform } from './transforms/BaseTransform';
2525
export { default as FormDataTransform } from './transforms/FormDataTransform';
26+
export { default as FuzzyDateTransform } from './transforms/FuzzyDate';
2627
export { default as NestedAttributesTransform } from './transforms/NestedAttributesTransform';
2728

2829
// Utils
@@ -32,6 +33,7 @@ export { default as Date } from './utils/Date';
3233
export { default as useDragDrop } from './utils/DragDrop';
3334
export { default as Element } from './utils/Element';
3435
export { default as Form } from './utils/Form';
36+
export { default as FuzzyDate } from './utils/FuzzyDate';
3537
export { default as Hooks } from './utils/Hooks';
3638
export { default as IIIF } from './utils/IIIF';
3739
export { default as Map } from './utils/Map';
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// @flow
2+
3+
class FuzzyDate {
4+
/**
5+
* Returns the passed date as a FuzzyDate input date.
6+
*
7+
* @param date
8+
*
9+
* @returns {{endDate: *, _destroy, accuracy, description, range, id, startDate: *}|null}
10+
*/
11+
toFuzzyDate(date) {
12+
if (!date) {
13+
return null;
14+
}
15+
16+
return {
17+
id: date.id,
18+
accuracy: date.accuracy,
19+
description: date.description,
20+
endDate: date.end_date,
21+
range: date.range,
22+
startDate: date.start_date,
23+
_destroy: date._destroy
24+
};
25+
}
26+
27+
/**
28+
* Returns the passed FuzzyDateable object for PUT/POST requests.
29+
*
30+
* @param dateable
31+
* @param attribute
32+
*
33+
* @returns {{}}
34+
*/
35+
toPayload(dateable, attribute) {
36+
const date = dateable[attribute];
37+
38+
if (!date) {
39+
return null;
40+
}
41+
42+
return {
43+
[attribute]: {
44+
id: date.id,
45+
accuracy: date.accuracy,
46+
description: date.description,
47+
end_date: date.endDate,
48+
range: date.range,
49+
start_date: date.startDate,
50+
_destroy: date._destroy
51+
}
52+
};
53+
}
54+
}
55+
56+
const FuzzyDateTransform: FuzzyDate = new FuzzyDate();
57+
export default FuzzyDateTransform;
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// @flow
2+
3+
import _ from 'underscore';
4+
import Calendar from './Calendar';
5+
import Browser from './Browser';
6+
7+
const DATE_SEPARATOR = ' - ';
8+
9+
const DEFAULT_CALENDAR = Calendar.Calendars.gregorian;
10+
11+
/**
12+
* Returns a view for the passed fuzzy date object and calendar.
13+
*
14+
* @param date
15+
* @param calendar
16+
*
17+
* @returns {null|string|*}
18+
*/
19+
const getDateView = (date, cal = null) => {
20+
if (!date) {
21+
return null;
22+
}
23+
24+
if (!(date.description || date.start_date)) {
25+
return null;
26+
}
27+
28+
let calendar = cal;
29+
30+
if (!calendar) {
31+
const locale = Browser.isBrowser() && navigator.language;
32+
calendar = new Calendar(locale, DEFAULT_CALENDAR);
33+
}
34+
35+
// Use the description, if provided
36+
if (date.description) {
37+
return date.description;
38+
}
39+
40+
// Otherwise, format the start and end dates
41+
const dateView = [];
42+
43+
if (date.start_date) {
44+
const parsed = calendar.parseDate(date.start_date);
45+
dateView.push(calendar.format(parsed, date.accuracy));
46+
}
47+
48+
if (date.range && date.end_date) {
49+
const parsed = calendar.parseDate(date.end_date);
50+
dateView.push(calendar.format(parsed, date.accuracy));
51+
}
52+
53+
return _.isEmpty(dateView) ? null : dateView.join(DATE_SEPARATOR);
54+
};
55+
56+
export default {
57+
getDateView
58+
};

packages/user-defined-fields/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/user-defined-fields",
3-
"version": "2.1.2",
3+
"version": "2.1.3",
44
"description": "A package of components used for allowing end users to define fields on models. Use with the \"user_defined_fields\" gem.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",
@@ -23,8 +23,8 @@
2323
"underscore": "^1.13.2"
2424
},
2525
"peerDependencies": {
26-
"@performant-software/semantic-components": "^2.1.2",
27-
"@performant-software/shared-components": "^2.1.2",
26+
"@performant-software/semantic-components": "^2.1.3",
27+
"@performant-software/shared-components": "^2.1.3",
2828
"react": ">= 16.13.1 < 19.0.0",
2929
"react-dom": ">= 16.13.1 < 19.0.0"
3030
},

0 commit comments

Comments
 (0)