@plusscommunities/pluss-core-web 1.2.7 → 1.2.10-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-core-web",
3
- "version": "1.2.7",
3
+ "version": "1.2.10-beta.0",
4
4
  "description": "Core extension package for Pluss Communities platform",
5
5
  "main": "dist/index.cjs.js",
6
6
  "scripts": {
7
7
  "build": "npm i && rollup -c",
8
+ "betapatch": "npm version prepatch --preid=beta",
8
9
  "patch": "npm version patch",
9
- "upload": "npm run build && npm publish --access public && rm -rf node_modules",
10
+ "betaupload": "npm run build && npm publish --access public --tag beta",
11
+ "betaupload:p": "npm run betapatch && npm run betaupload",
12
+ "upload": "npm run build && npm publish --access public",
10
13
  "upload:p": "npm run patch && npm run upload"
11
14
  },
12
15
  "author": "Phillip Suh",
@@ -0,0 +1,15 @@
1
+ import { TEMPLATES_LOADED, TEMPLATE_REMOVED } from './types';
2
+
3
+ export const templatesLoaded = (template) => {
4
+ return {
5
+ type: TEMPLATES_LOADED,
6
+ payload: template,
7
+ };
8
+ };
9
+
10
+ export const removeTemplate = (id) => {
11
+ return {
12
+ type: TEMPLATE_REMOVED,
13
+ payload: id,
14
+ };
15
+ };
@@ -1,21 +1,5 @@
1
- // export * from './AlertActions';
2
1
  export * from './AuthActions';
3
- // export * from './EventActions';
4
- // export * from './FeedbackActions';
5
- // export * from './FoodActions';
6
- // export * from './NewsActions';
7
- // export * from './JobsActions';
8
- // export * from './KeysActions';
9
2
  export * from './LocalActions';
10
3
  export * from './UsersActions';
11
- // export * from './ContactsActions';
12
- // export * from './MapsActions';
13
- // export * from './MarketActions';
14
4
  export * from './NavActions';
15
- // export * from './InfoPagesActions';
16
- // export * from './ServiceActions';
17
- // export * from './MediaActions';
18
- // export * from './FacilityActions';
19
- // export * from './DeviceActions';
20
- // export * from './FormActions';
21
- // export * from './AutomationActions';
5
+ export * from './TemplateActions';
@@ -16,3 +16,6 @@ export const INVITE_CODE_UPDATED = 'INVITE_CODE_UPDATED';
16
16
  export const INVITE_CODE_REMOVED = 'INVITE_CODE_REMOVED';
17
17
 
18
18
  export const SET_NAV_DATA = 'SET_NAV_DATA';
19
+
20
+ export const TEMPLATES_LOADED = 'TEMPLATES_LOADED';
21
+ export const TEMPLATE_REMOVED = 'TEMPLATE_REMOVED';
package/src/apis/index.js CHANGED
@@ -6,3 +6,4 @@ export * from './stringActions';
6
6
  export * from './userActions';
7
7
  export * from './profileActions';
8
8
  export * from './utilityActions';
9
+ export * from './templateActions';
@@ -0,0 +1,41 @@
1
+ import { getUrl, htmlEncode } from '../helper';
2
+ import { authedFunction } from '../session';
3
+
4
+ export const templateActions = {
5
+ getTemplates: (site, featureKey) => {
6
+ const query = { site, featureKey };
7
+ return authedFunction({
8
+ method: 'GET',
9
+ url: getUrl('templates', 'get/list', query),
10
+ });
11
+ },
12
+ getTemplate: (site, featureKey, rowId) => {
13
+ return authedFunction({
14
+ method: 'GET',
15
+ url: getUrl('templates', 'get/single', { site, featureKey, rowId }),
16
+ });
17
+ },
18
+ createTemplate: (template) => {
19
+ template.content = htmlEncode(template.content);
20
+ return authedFunction({
21
+ method: 'POST',
22
+ url: getUrl('templates', 'update/add'),
23
+ data: template,
24
+ });
25
+ },
26
+ editTemplate: (template) => {
27
+ template.content = htmlEncode(template.content);
28
+ return authedFunction({
29
+ method: 'POST',
30
+ url: getUrl('templates', 'update/edit'),
31
+ data: template,
32
+ });
33
+ },
34
+ deleteTemplate: (site, rowId) => {
35
+ return authedFunction({
36
+ method: 'POST',
37
+ url: getUrl('templates', 'update/delete'),
38
+ data: { site, rowId },
39
+ });
40
+ },
41
+ };
@@ -75,7 +75,7 @@ class AudienceSelector extends Component {
75
75
 
76
76
  getAudienceTypeSelection() {
77
77
  const { AudienceType, AudienceTagList, Category, Tag, Type } = this.state;
78
- if (AudienceType === 'Custom') return AudienceTagList;
78
+ if (AudienceType === 'Custom') return AudienceTagList || [];
79
79
  if (AudienceType === 'Category') return Category;
80
80
  if (AudienceType === 'UserTags') return Tag;
81
81
  return Type;
@@ -135,6 +135,7 @@ class AudienceSelector extends Component {
135
135
  Category: '',
136
136
  includeList: [],
137
137
  excludeList: [],
138
+ AudienceTagList: [],
138
139
  });
139
140
  setTimeout(this.onChangeSelection, 50);
140
141
  }
@@ -149,7 +149,7 @@ class TimePicker extends Component {
149
149
  const { disabled } = this.props;
150
150
  if (disabled) {
151
151
  return (
152
- <div className="timepicker disabled">
152
+ <div className="timepicker disabled" style={this.props.style}>
153
153
  <span
154
154
  className="timepicker__span"
155
155
  style={this.props.inputStyle}
@@ -158,7 +158,7 @@ class TimePicker extends Component {
158
158
  );
159
159
  }
160
160
  return (
161
- <div className={`timepicker ${this.props.className}`}>
161
+ <div className={`timepicker ${this.props.className}`} style={this.props.style}>
162
162
  <input
163
163
  className="timepicker__input"
164
164
  maxLength="2"
@@ -23,6 +23,8 @@ export { default as isUrl } from './strings/isUrl';
23
23
  export { default as randomString } from './strings/randomString';
24
24
  export { default as toParagraphed } from './strings/toParagraphed';
25
25
  export { default as onlyAlphanumeric } from './strings/onlyAlphanumeric';
26
+ export { default as htmlDecode } from './strings/htmlDecode';
27
+ export { default as htmlEncode } from './strings/htmlEncode';
26
28
 
27
29
  // site
28
30
  export { default as getSiteName } from './site/getSiteName';
@@ -0,0 +1,4 @@
1
+ import $ from 'jquery';
2
+
3
+ const htmlDecode = (value) => $('<textare/>').html(value).text();
4
+ export default htmlDecode;
@@ -0,0 +1,4 @@
1
+ import $ from 'jquery';
2
+
3
+ const htmlEncode = (value) => $('<textare/>').text(value).html();
4
+ export default htmlEncode;
package/src/index.js CHANGED
@@ -6,5 +6,6 @@ import * as Colours from './colours';
6
6
  import * as Actions from './actions';
7
7
  import * as Apis from './apis';
8
8
  import * as Components from './components';
9
+ import { Reducers } from './reducers';
9
10
 
10
- export { Config, Session, Analytics, Helper, Colours, Actions, Apis, Components };
11
+ export { Config, Session, Analytics, Helper, Colours, Actions, Apis, Components, Reducers };
@@ -0,0 +1,29 @@
1
+ import _ from 'lodash';
2
+
3
+ import { TEMPLATES_LOADED, TEMPLATE_REMOVED } from '../actions/types';
4
+
5
+ const INITIAL_STATE = {
6
+ list: [],
7
+ };
8
+
9
+ export default (state = INITIAL_STATE, action) => {
10
+ switch (action.type) {
11
+ case TEMPLATES_LOADED:
12
+ const result = _.unionWith(action.payload, state.list, (v1, v2) => {
13
+ return v1 != null && v2 != null && v1.RowId === v2.RowId;
14
+ });
15
+ return { ...state, list: result };
16
+ case TEMPLATE_REMOVED:
17
+ const index = _.findIndex(state.list, (app) => {
18
+ return app != null && app.RowId === action.payload;
19
+ });
20
+ if (index > -1) {
21
+ const newTemplates = [...state.list];
22
+ newTemplates.splice(index, 1);
23
+ return { ...state, list: newTemplates };
24
+ }
25
+ return state;
26
+ default:
27
+ return state;
28
+ }
29
+ };
@@ -0,0 +1,3 @@
1
+ import TemplatesReducer from './TemplatesReducer';
2
+
3
+ export const Reducers = { templates: TemplatesReducer };