Skip to content

Commit 11baa26

Browse files
committed
fix: correct logic for history route to work
ref: #26 #28 nofusscomputing/centurion_erp#248 fixes #25
1 parent 9200914 commit 11baa26

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

.vscode/extensions.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"recommendations": [
33
"orta.vscode-jest",
4-
"eg2.vscode-npm-script",
54
"burkeholland.simple-react-snippets"
65
]
76
}

src/App.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,12 @@ function App() {
5151
>
5252
<Route path='/login' element={<Login/>}/>
5353

54-
<Route path="/core/:model/:pk/:action"
54+
<Route path="/core/:model/:pk/history"
5555
element={<History
5656
setContentHeading={setContentHeading}
5757
SetContentHeaderIcon={SetContentHeaderIcon}
5858
/>}
5959
errorElement={<ErrorPage /> }
60-
loader = {detailsLoader}
6160
/>
6261

6362
<Route path="/settings"

src/components/Table.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ const Table = ({
261261
<td
262262
onClick={(e) => {
263263
let a = e
264-
document.getElementById('expandable-' + e.currentTarget.parentElement.id).classList.toggle("hide-expandable-row")
264+
document.getElementById('expandable-' + data.id).classList.toggle("hide-expandable-row")
265265
}}
266266
>
267267
<IconLoader

src/hooks/urlBuilder.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ export default function urlBuilder(
6363
pk = params.pk
6464
}
6565

66-
if( ! module && path_directories[0] == 'settings' ) {
66+
if( ! module ) {
6767

68-
module = 'settings'
68+
module = path_directories[0]
6969

7070
}
7171

@@ -75,12 +75,10 @@ export default function urlBuilder(
7575

7676
}
7777

78-
7978
const allowed_actions = [ 'add', 'delete', 'edit' ]
8079

8180
if( ! allowed_actions.includes( action ) ) {
8281

83-
action = null
8482

8583
for( let dir of path_directories ) {
8684

@@ -90,6 +88,12 @@ export default function urlBuilder(
9088
}
9189
}
9290

91+
if( ! action && path_directories[path_directories.length-1] == 'history' ) {
92+
93+
action = 'history'
94+
}
95+
96+
9397
const ticket_models = [
9498
'change',
9599
'incident',
@@ -294,6 +298,9 @@ export default function urlBuilder(
294298

295299
method = 'PATCH'
296300

301+
} else if( action === 'history' ) {
302+
303+
url += '/history'
297304
}
298305

299306
if(

src/layout/history.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const History = ({
2222
<div className="content">
2323
<Table
2424
callback={setContentHeading}
25-
data_url_path={'core/' + url_builder.model + '/' + url_builder.pk + '/history'}
25+
data_url_path={'core/' + url_builder.params.model + '/' + url_builder.params.pk + '/history'}
2626
/>
2727
</div>
2828
</section>

0 commit comments

Comments
 (0)