@corpsmap/corpsmap 3.1.7 → 3.1.8

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@corpsmap/corpsmap",
3
- "version": "3.1.7",
3
+ "version": "3.1.8",
4
4
  "description": "CorpsMap as React Components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,243 @@
1
+ export default {
2
+ name: "questionsTab",
3
+
4
+ getReducer: () => {
5
+ const initialData = {
6
+ questionsTabStatus: false,
7
+ errorList: {},
8
+ applicationName: "",
9
+ emailPath: ""
10
+ };
11
+ return (state = initialData, { type, payload }) => {
12
+ switch (type) {
13
+ case "PARAMETERS_SET":
14
+ case "FORM_SUBMITTED":
15
+ case "FORM_ERROR":
16
+ case "API_POST_SUCCESS":
17
+ case "API_POST_ERROR":
18
+ case "ACTIVATE_QUESTIONS_TAB":
19
+ case "DEACTIVATE_QUESTIONS_TAB":
20
+ case "VALIDATION_COMPLETE":
21
+ return Object.assign({}, state, payload);
22
+ default:
23
+ return state;
24
+ }
25
+ };
26
+ },
27
+ doHandleFormErrors:
28
+ (outputs) =>
29
+ ({ dispatch, store }) => {
30
+
31
+ let formErrors = store.selectErrorList();
32
+ let formValidation = true;
33
+ const regex = /[a-zA-Z]/g;
34
+
35
+ //First Name
36
+ if (outputs.first_Name == " ") {
37
+ formValidation = false;
38
+ formErrors["First_Name"] =" *Field Cannot be empty ";
39
+ }
40
+
41
+ if (typeof outputs.first_Name !== "undefined") {
42
+ if (!outputs.first_Name.match(regex)) {
43
+ formValidation = false;
44
+ formErrors["First_Name"] = " *Only letters ";
45
+ }
46
+ }
47
+
48
+ //Last Name
49
+ if (outputs.last_Name == " ") {
50
+ formValidation = false;
51
+ formErrors["Last_Name"] = " *Field Cannot be empty ";
52
+ }
53
+
54
+ if (typeof outputs.last_Name !== "undefined") {
55
+ if (!outputs.last_Name.match(regex)) {
56
+ formValidation = false;
57
+ formErrors["Last_Name"] = " *Only letters ";
58
+ }
59
+ }
60
+
61
+ //Email
62
+ if (outputs.e_mail == " ") {
63
+ formValidation = false;
64
+ formErrors["email"] = " *Field Cannot be empty ";
65
+ }
66
+
67
+ if (typeof outputs.e_mail !== "undefined") {
68
+ let lastAtPos = outputs.e_mail.lastIndexOf("@");
69
+ let lastDotPos = outputs.e_mail.lastIndexOf(".");
70
+
71
+ if (
72
+ !(
73
+ lastAtPos < lastDotPos &&
74
+ lastAtPos > 0 &&
75
+ outputs.e_mail.indexOf("@@") == -1 &&
76
+ lastDotPos > 2 &&
77
+ outputs.e_mail.length - lastDotPos > 2
78
+ )
79
+ ) {
80
+ formValidation = false;
81
+ formErrors["email"] = " *Email is not valid ";
82
+ }
83
+ }
84
+ // Select issue
85
+ if (outputs.sel_issue == " ") {
86
+ formValidation = false;
87
+ formErrors["issue"] = " *Please select an issue ";
88
+ }
89
+
90
+ // Breif Description
91
+ if (outputs.add_comments == " ") {
92
+ formValidation = false;
93
+ formErrors["add_comments"] = " *Please provide a breif description of issue ";
94
+ }
95
+
96
+ dispatch({
97
+ type: "VALIDATION_COMPLETE",
98
+ payload: {
99
+ errorList: formErrors,
100
+ },
101
+ });
102
+ return formValidation;
103
+
104
+
105
+ },
106
+ doSetContactFormConfiguration:
107
+ (fudsFormParams) =>
108
+ ({ dispatch, store}) => {
109
+
110
+ const app_name = fudsFormParams.application_name
111
+ const app_path = fudsFormParams.email_url
112
+
113
+ dispatch({
114
+ type: "PARAMETERS_SET",
115
+ payload: {
116
+ applicationName:app_name,
117
+ emailPath:app_path
118
+ },
119
+ });
120
+ },
121
+ doSetContactFormIssues:
122
+ (issues) =>
123
+ ({ dispatch, apiPost }) => {
124
+ console.log(issues);
125
+
126
+ // Here we want to POST the contents of the Form
127
+ // (path, payload, callback)
128
+
129
+ const path = store.selectEmailPath();
130
+
131
+ const params = {
132
+ application_name: store.selectApplicationName(),
133
+ first_name: issues.first_Name,
134
+ last_name: issues.last_Name,
135
+ email_address: issues.e_mail,
136
+ category: issues.sel_issue,
137
+ comments: issues.add_comments
138
+ };
139
+
140
+ apiPost(path ,params , (err, response, body) => {
141
+ if(err || response.statusCode !== 200){
142
+ console.log(err, response);
143
+ dispatch({
144
+ type:"API_POST_ERROR",
145
+ payload: {
146
+ notification: {
147
+ message: "api-error",
148
+ level: "danger",
149
+ },
150
+ },
151
+ });
152
+ }else{
153
+ dispatch({
154
+ type:"API_POST_SUCCESS",
155
+ payload: {
156
+ notification: {
157
+ message: "api-success",
158
+ level: "success",
159
+ },
160
+ },
161
+ });
162
+ console.log(response)
163
+ }
164
+ });
165
+ },
166
+ doSubmitNotification:
167
+ (bool) =>
168
+ ({ dispatch, store }) => {
169
+
170
+ if(bool){
171
+ store.doNotificationsFire({
172
+ title: "Form Submitted",
173
+ message: "Form Submitted",
174
+ level: "success",
175
+ });
176
+ dispatch({
177
+ type: "FORM_SUBMITTED",
178
+ payload: {},
179
+ });
180
+ }else{
181
+ store.doNotificationsFire({
182
+ title: "Form Error",
183
+ message: "Form Has Errors",
184
+ level: "danger",
185
+ });
186
+ dispatch({
187
+ type: "FORM_ERROR",
188
+ payload: {},
189
+ });
190
+
191
+ }
192
+ },
193
+ doSubmitNotification:
194
+ (bool) =>
195
+ ({ dispatch, store }) => {
196
+
197
+ if(bool){
198
+ store.doNotificationsFire({
199
+ title: "Form Submitted",
200
+ message: "Form Submitted",
201
+ level: "success",
202
+ });
203
+ dispatch({
204
+ type: "FORM_SUBMITTED",
205
+ payload: {},
206
+ });
207
+ }else{
208
+ store.doNotificationsFire({
209
+ title: "Form Error",
210
+ message: "Form Has Errors",
211
+ level: "danger",
212
+ });
213
+ dispatch({
214
+ type: "FORM_ERROR",
215
+ payload: {},
216
+ });
217
+
218
+ }
219
+ },
220
+ doQuestionBarActivate:
221
+ () =>
222
+ ({ dispatch }) => {
223
+ dispatch({
224
+ type: "ACTIVATE_QUESTIONS_TAB",
225
+ payload: {
226
+ questionsTabStatus: true,
227
+ },
228
+ });
229
+ },
230
+
231
+ selectApplicationName: (state) => {
232
+ return state.questionsTab.applicationName;
233
+ },
234
+ selectEmailPath: (state) => {
235
+ return state.questionsTab.emailPath;
236
+ },
237
+ selectQuestionsTabStatus: (state) => {
238
+ return state.questionsTab.questionsTabStatus;
239
+ },
240
+ selectErrorList: (state) => {
241
+ return state.questionsTab.errorList;
242
+ },
243
+ };
@@ -0,0 +1,17 @@
1
+ import questionsTab from "./question-button";
2
+ import bundle from "./bundle";
3
+
4
+ const plugin = {
5
+ pluginName: "questionsTab",
6
+ enabled: true,
7
+ bundle: bundle,
8
+ components: [
9
+ {
10
+ component: questionsTab,
11
+ region: "right-sidebar-top",
12
+ sortOrder: 100,
13
+ },
14
+ ],
15
+ };
16
+
17
+ export default plugin;
@@ -0,0 +1,36 @@
1
+ import React from "react";
2
+ import { connect } from "redux-bundler-react";
3
+ import { SidebarButton } from "../../application-controls/index";
4
+ import QuestionModal from "./question-modal";
5
+
6
+ class questionsTab extends React.Component {
7
+ constructor(props) {
8
+ super(props);
9
+ this.handleClick = this.handleClick.bind(this);
10
+ }
11
+ handleClick() {
12
+ const { doModalOpen } = this.props;
13
+ doModalOpen({
14
+ children: [QuestionModal],
15
+ options: {},
16
+ openedBy: "questionsTab",
17
+ });
18
+ }
19
+ render() {
20
+ return (
21
+ <SidebarButton
22
+ iconClass="mdi mdi-help-circle"
23
+ label="Contact Us"
24
+ title="Contact Us"
25
+ onClick={this.handleClick}
26
+ />
27
+ );
28
+ }
29
+ }
30
+
31
+ export default connect(
32
+ "doModalOpen",
33
+ "doQuestionBarActivate",
34
+ "selectQuestionsTabStatus",
35
+ questionsTab
36
+ );
@@ -0,0 +1,191 @@
1
+ import React from "react";
2
+ import { connect } from "redux-bundler-react";
3
+
4
+ class QuestionsModal extends React.Component {
5
+ constructor(props) {
6
+ super(props);
7
+
8
+ this.state = {
9
+ firstName: " ",
10
+ lastName: " ",
11
+ Email: " ",
12
+ selIssue: " ",
13
+ addComments: " ",
14
+ errors: {},
15
+ };
16
+ this.close = this.close.bind(this);
17
+ this.handleChange = this.handleChange.bind(this);
18
+ this.handleSubmit = this.handleSubmit.bind(this);
19
+ }
20
+
21
+ close() {
22
+ const { doModalClose } = this.props;
23
+ doModalClose();
24
+ }
25
+
26
+ handleChange(event) {
27
+ switch (event.target.name) {
28
+ case "FN":
29
+ this.setState({ firstName: event.target.value });
30
+ break;
31
+ case "LN":
32
+ this.setState({ lastName: event.target.value });
33
+ break;
34
+ case "EM":
35
+ this.setState({ Email: event.target.value });
36
+ break;
37
+ case "SI":
38
+ this.setState({ selIssue: event.target.value });
39
+ break;
40
+ case "AC":
41
+ this.setState({ addComments: event.target.value });
42
+ break;
43
+ default:
44
+ }
45
+ }
46
+
47
+ handleSubmit(event) {
48
+ event.preventDefault();
49
+ const { doSetContactFormIssues, doHandleFormErrors, doSubmitNotification, errorList } = this.props;
50
+ const formOutputs = {
51
+ first_Name: this.state.firstName,
52
+ last_Name: this.state.lastName,
53
+ e_mail: this.state.Email,
54
+ sel_issue: this.state.selIssue,
55
+ add_comments: this.state.addComments,
56
+ };
57
+
58
+ const formIsValid = doHandleFormErrors(formOutputs)
59
+
60
+ this.setState({
61
+ errors: errorList
62
+ })
63
+
64
+ if (formIsValid) {
65
+ doSetContactFormIssues(formOutputs);
66
+ doSubmitNotification(formIsValid);
67
+ this.close();
68
+
69
+ } else {
70
+ doSubmitNotification(formIsValid);
71
+ }
72
+
73
+ }
74
+ render() {
75
+ const { theme } = this.props;
76
+
77
+ return (
78
+ <div>
79
+ <div className={"cm-modal-header " + theme}>Questions</div>
80
+ <div
81
+ className="cm-modal-body"
82
+ style={{ height: 290, top: 0, bottom: 0, left: 0, right: 0 }}
83
+ >
84
+ <div className="cm-form-group">
85
+ <form onSubmit={this.handleSubmit}>
86
+ <div>
87
+ <label>
88
+ First Name:{" "}
89
+ <input
90
+ name="FN"
91
+ type="text"
92
+ value={this.state.firstName}
93
+ onChange={this.handleChange}
94
+ ></input>
95
+ <label style={{color: "red" , position: "relative", left: 10}}>{this.state.formIsValid ? null: this.state.errors["First_Name"]}</label>
96
+ </label>
97
+ <label style={{position: "relative", left: 20}}>
98
+ Last Name:{" "}
99
+ <input
100
+ name="LN"
101
+ type="text"
102
+ value={this.state.LastName}
103
+ onChange={this.handleChange}
104
+ ></input>
105
+ <label style={{color: "red", position: "relative", left: 10}}>{this.state.formIsValid ? null: this.state.errors["Last_Name"]}</label>
106
+ </label>
107
+ </div>
108
+ <br></br>
109
+ <div>
110
+ <label>
111
+ Email{" "}
112
+ <input
113
+ name="EM"
114
+ style={{ width: 250 }}
115
+ type="text"
116
+ value={this.state.Email}
117
+ onChange={this.handleChange}
118
+ ></input>
119
+ <label style={{color: "red", position: "relative", left: 10}}>{this.state.formIsValid ? null: this.state.errors["email"]}</label>
120
+ </label>
121
+ </div>
122
+ <br></br>
123
+ <div>
124
+ <label>
125
+ Select your Current Issue:
126
+ <select
127
+ name="SI"
128
+ style={{ width: 150, textAlign: "center" }}
129
+ value={this.state.selIssue}
130
+ onChange={this.handleChange}
131
+ >
132
+ <option value=" "> </option>
133
+ <option value=" Map Issue "> Map Issue </option>
134
+ <option value=" Errors "> Errors</option>
135
+ <option value=" Bugs "> Bugs </option>
136
+ <option value=" Requests "> Requests </option>
137
+ <option value=" Other"> Other </option>
138
+ </select>
139
+ <label style={{color: "red", position: "relative", left: 10}}>{this.state.formIsValid ? null: this.state.errors["issue"]}</label>
140
+ </label>
141
+ </div>
142
+ <br></br>
143
+ <div>
144
+ <p>Brief Description</p>
145
+
146
+ <textarea
147
+ name="AC"
148
+ style={{ height: 120, width: 300 }}
149
+ value={this.state.addComments}
150
+ onChange={this.handleChange}
151
+ ></textarea>
152
+ <label style={{color: "red", position: "relative", left: 10}}>{this.state.formIsValid ? null: this.state.errors["add_comments"]}</label>
153
+ </div>
154
+ </form>
155
+ </div>
156
+ </div>
157
+ <div className="cm-modal-footer">
158
+ <br></br>
159
+ <br></br>
160
+ <br></br>
161
+ <button
162
+ type="submit"
163
+ className={"cm-btn cm-btn-theme " + theme}
164
+ onClick={this.handleSubmit}
165
+ >
166
+ Submit
167
+ </button>
168
+ <button
169
+ style={{ textAlign: "left" }}
170
+ type="Close"
171
+ className={"cm-btn cm-btn-theme " + theme}
172
+ onClick={this.close}
173
+ >
174
+ Close
175
+ </button>
176
+ </div>
177
+ </div>
178
+
179
+ );
180
+ }
181
+ }
182
+
183
+ export default connect(
184
+ "selectTheme",
185
+ "doModalClose",
186
+ "doSubmitNotification",
187
+ "doSetContactFormIssues",
188
+ "doHandleFormErrors",
189
+ "selectErrorList",
190
+ QuestionsModal
191
+ );
package/src/index.js CHANGED
@@ -39,6 +39,7 @@ import legend from "./core-plugins/legend";
39
39
  import measureTools from "./core-plugins/measure-tools";
40
40
  import permalink from "./core-plugins/permalink";
41
41
  import printMap from "./core-plugins/print-map";
42
+ import questionsTab from "./core-plugins/contact-form"
42
43
  import rasterIdent from "./core-plugins/identify-raster";
43
44
  import rotateNorth from "./core-plugins/rotate-north";
44
45
  import themeSwitcher from "./core-plugins/theme-switcher";
@@ -90,6 +91,7 @@ export {
90
91
  measureTools,
91
92
  permalink,
92
93
  printMap,
94
+ questionsTab,
93
95
  rasterIdent,
94
96
  rotateNorth,
95
97
  themeSwitcher,