Skip to content

Commit 12bcaec

Browse files
authored
Fb new animal wizard dev (#279)
* Hamsters are acquired in bulk - changes made to Acquisition Panel to allow user to specify the number of hamsters to be added. * 1. Changes need to be made to Acquisition Panel, NewAnimalPage, and SaveModal to allow user to specify the number of hamsters to be added. 2. Updated PotentialDams and PotentialSires queries to include gestational age for hamsters * Fixed formatting * Updated snapshots * 1. Automated testing and styling changes for hamster acquisition changes. 2. Updated snapshots * LabKey's DbSequence manager doesn't provide the necessary functionality to handle SNPRC animal ID's. SNPRC_EHRSequencer class was updated to allow deleted IDs to be placed back in the queue for reassignment in the future. 1. added snprc_ehr.Counters table to manage sequences 2. refactored SNPRC_EHRSequencer to manage sequences in new counters table 3. fixed save error reporting in NewAnimalPage.jsx 4. tweaked InfoPanel message formats 5. updated updateAnimalData.js API to be aware of multiple ID requests 6. updated snapshots 7. incremented snprc_ehr module version * Updated snapshot
1 parent 189b9a4 commit 12bcaec

15 files changed

Lines changed: 361 additions & 116 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*******************************************************
2+
Counters table for SNPRC_EHRSequencer
3+
Creator: thawkins
4+
Date: 08/21/2020
5+
*******************************************************/
6+
7+
CREATE TABLE snprc_ehr.Counters
8+
(
9+
RowId INT IDENTITY(1,1) NOT NULL,
10+
Name NVARCHAR(255) NOT NULL,
11+
Value INT NOT NULL,
12+
Container dbo.ENTITYID NOT NULL,
13+
ObjectId UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID(),
14+
CONSTRAINT PK_snprc_Counters PRIMARY KEY (RowId),
15+
CONSTRAINT FK_Counters_Container FOREIGN KEY (Container) REFERENCES core.Containers (EntityId)
16+
);
17+
GO
18+
19+
CREATE UNIQUE INDEX idx_snprc_container_NameValue ON snprc_ehr.Counters (Container, Name, Value);
20+
GO

snprc_ehr/src/client/NewAnimalPage/NewAnimalPage.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ export default class NewAnimalPage extends React.Component {
308308

309309
for (let i = 0; i < numAnimals; i++) {
310310
// run async save then dismiss modal
311-
uploadAnimalData(this.state.newAnimalData)
311+
uploadAnimalData(this.state.newAnimalData, numAnimals)
312312
.then(data => {
313313
if (data.success === true) {
314314
this.setState(
@@ -337,7 +337,7 @@ export default class NewAnimalPage extends React.Component {
337337
.catch(error => {
338338
this.setState(prevState => ({
339339
...prevState,
340-
errorMessage: error.exception,
340+
errorMessage: error.message,
341341
showSaveModal: false,
342342
}))
343343
})
@@ -349,6 +349,7 @@ export default class NewAnimalPage extends React.Component {
349349
this.setState(prevState => ({
350350
...prevState,
351351
currentPanel: 1,
352+
errorMessage: undefined,
352353
numAnimals: undefined,
353354
newAnimalData: {
354355
...prevState.newAnimalData,
@@ -619,7 +620,6 @@ export default class NewAnimalPage extends React.Component {
619620
</div>
620621
</div>
621622
) }
622-
623623
{ this.state.errorMessage && (
624624
<InfoPanel
625625
errorMessages={
@@ -632,7 +632,6 @@ export default class NewAnimalPage extends React.Component {
632632
}
633633
/>
634634
) }
635-
636635
<div>
637636
<Pager className="pager-container">
638637
<Pager.Item

snprc_ehr/src/client/NewAnimalPage/api/updateAnimalData.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,19 @@ const convertToJson = newAnimalData => {
2323
return jsonData
2424
}
2525

26-
export const uploadAnimalData = newAnimalData => {
27-
const url = ActionURL.buildURL('snprc_ehr', 'UpdateAnimalData.api')
26+
export const uploadAnimalData = (newAnimalData, numAnimals) => {
27+
const isMultipleSequenceRequest = (numAnimals > 1)
28+
const url = `${ActionURL.buildURL('snprc_ehr', 'UpdateAnimalData.api')}?isMultipleSequenceRequest=${isMultipleSequenceRequest}`
2829
return new Promise((resolve, reject) => {
2930
Ajax.request({
3031
method: 'POST',
3132
url,
3233
jsonData: convertToJson(newAnimalData),
3334
success: Utils.getCallbackWrapper(data => {
34-
resolve(data)
35+
if (data.success === false)
36+
reject(new Error(data.message))
37+
else
38+
resolve(data)
3539
}),
3640
failure: Utils.getCallbackWrapper(error => {
3741
reject(error)

snprc_ehr/src/client/NewAnimalPage/components/AcquisitionPanel.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ export default class AcquisitionPanel extends React.Component {
120120
) }
121121
</div>
122122
<InfoPanel
123-
errorMessages={
123+
errorMessages={ this.state.errorMessage && (
124124
[{ propTest: this.state.errorMessage, colName: this.state.errorMessage }]
125-
}
125+
)}
126126
messages={
127127
[{ propTest: !acquisitionType, colName: 'Acquisition Code' }]
128128
}

snprc_ehr/src/client/NewAnimalPage/components/LocationPanel.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ export default class LocationPanel extends React.Component {
127127
</div>
128128
</div>
129129
<InfoPanel
130-
errorMessages={
130+
errorMessages={ this.state.errorMessage && (
131131
[{ propTest: this.state.errorMessage, colName: this.state.errorMessage }]
132-
}
132+
)}
133133
messages={
134134
[{ propTest: !room, colName: 'Location' }]
135135
}

snprc_ehr/src/client/NewAnimalPage/tests/components/__snapshots__/AcquisitionPanel.test.jsx.snap

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@ exports[`AcquisitionPanel tests Should render the AcquisitionPanel 1`] = `
7575
</div>
7676
</div>
7777
<InfoPanel
78-
errorMessages={
79-
Array [
80-
Object {
81-
"colName": undefined,
82-
"propTest": undefined,
83-
},
84-
]
85-
}
8678
messages={
8779
Array [
8880
Object {
@@ -194,14 +186,6 @@ exports[`AcquisitionPanel tests Should render the AcquisitionPanel for multiple
194186
</div>
195187
</div>
196188
<InfoPanel
197-
errorMessages={
198-
Array [
199-
Object {
200-
"colName": undefined,
201-
"propTest": undefined,
202-
},
203-
]
204-
}
205189
infoMessages={
206190
Array [
207191
Object {

snprc_ehr/src/client/NewAnimalPage/tests/components/__snapshots__/LocationPanel.test.jsx.snap

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,6 @@ exports[`Should render the LocationPanel 1`] = `
100100
</div>
101101
</div>
102102
<InfoPanel
103-
errorMessages={
104-
Array [
105-
Object {
106-
"colName": undefined,
107-
"propTest": undefined,
108-
},
109-
]
110-
}
111103
messages={
112104
Array [
113105
Object {

snprc_ehr/src/client/Shared/components/InfoPanel.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,15 @@ export default class InfoPanel extends React.PureComponent {
3232
) }
3333
{ infoMessages
3434
&& (
35-
<span className="info-div">
35+
<div className="info-div">
3636
<div className="info-text-span">
3737
{ infoMessages.map( (message, index) => {
3838
const msg = includeBullets ? `${index + 1} ) ${message.value}` : message.value
3939
return <div key={ message.key } >{ msg }</div>
4040
}) }
4141
</div>
42-
</span>
42+
</div>
4343
) }
44-
4544
</span>
4645
</div>
4746
</>

snprc_ehr/src/client/Shared/styles/components/_infoPanel.scss

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,18 @@
2828
}
2929

3030
.info-err-span {
31-
background-color: $disabled-gray;
32-
border: 1px solid $info-red;
33-
border-radius: 3px;
34-
color: $info-red;
31+
// background-color: $disabled-gray;
32+
// border: 1px solid $info-red;
33+
// border-radius: 3px;
34+
35+
color: black;
3536
padding: 0.2rem;
3637
}
3738

3839
.info-err-div {
39-
padding: 1rem 0 0 0;
40+
padding: 1rem;
4041
font-weight: 600;
42+
background-color: $info-light-red;
43+
border: 1px solid $info-light-red;
44+
border-radius: 3px;
4145
}

snprc_ehr/src/client/Shared/styles/settings.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ $button-blue: #282aa5;
77
$dark-blue: #364051;
88
$off-white: #f7f7f7;
99
$info-red: #c24343;
10+
$info-light-red: #e06d6d;
1011
$info-blue: #100796;
1112
$tooltip-yellow: #e7e693;
1213
$info-green: #7aec76c2;

0 commit comments

Comments
 (0)