Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
GGCE
GGCE Web
Commits
34d9e6fb
Commit
34d9e6fb
authored
Apr 28, 2022
by
Maksym Tishchenko
Browse files
Methods: Edit
parent
fede45a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
workspaces/ui-express/src/method/ui/MethodBrowsePage.tsx
View file @
34d9e6fb
...
...
@@ -44,6 +44,9 @@ export const MethodTableDefaultConfig = {
id
:
{
readonly
:
true
,
align
:
TextAlign
.
right
},
},
columnRenderers
:
{
name
:
({
value
,
actions
,
row
}:
{
value
:
string
,
actions
:
{[
key
:
string
]:
(...
args
)
=>
void
},
row
:
Method
}):
JSX
.
Element
=>
(
!
P
.
allowedAccess
(
P
.
MethodData
,
P
.
write
)
?
<>
{
value
}
</>
:
<
a
onClick
=
{
()
=>
actions
.
selectMethod
(
row
.
id
)
}
>
{
value
}
</
a
>
),
studyReasonCode
:
({
value
}:
{
value
:
string
})
=>
<
CodeValueDisplay
codeGroup
=
{
Method
.
CodeGroup
.
studyReasonCode
}
value
=
{
value
}
/>,
georeferenceDatum
:
({
value
}:
{
value
:
string
})
=>
<
CodeValueDisplay
codeGroup
=
{
Method
.
CodeGroup
.
georeferenceDatum
}
value
=
{
value
}
/>,
georeferenceProtocolCode
:
({
value
}:
{
value
:
string
})
=>
<
CodeValueDisplay
codeGroup
=
{
Method
.
CodeGroup
.
georeferenceProtocolCode
}
value
=
{
value
}
/>,
...
...
@@ -65,6 +68,7 @@ class BrowsePage extends React.Component<PropsFromRedux & WithTranslation & With
public
state
=
{
selected
:
[],
methodDialogIsOpen
:
false
,
selectedMethodId
:
null
,
createNew
:
true
,
};
...
...
@@ -87,19 +91,25 @@ class BrowsePage extends React.Component<PropsFromRedux & WithTranslation & With
this
.
setState
({
selected
:
selectedIds
});
}
private
selectMethod
=
(
id
)
=>
{
this
.
setState
({
selectedMethodId
:
id
})
this
.
openMethodDialog
(
false
)
}
private
openMethodDialog
=
(
createNew
=
true
)
=>
{
this
.
setState
({
methodDialogIsOpen
:
true
,
createNew
});
};
private
closeMethodDialog
=
()
=>
{
this
.
setState
({
methodDialogIsOpen
:
false
,
createNew
:
true
});
this
.
setState
({
methodDialogIsOpen
:
false
,
createNew
:
true
,
selectedMethodId
:
null
});
};
public
render
()
{
const
{
t
,
onSortChange
,
applyFilter
,
loadMore
,
data
}
=
this
.
props
;
const
{
selected
,
methodDialogIsOpen
,
createNew
}
=
this
.
state
;
const
{
selected
,
methodDialogIsOpen
,
selectedMethodId
,
createNew
}
=
this
.
state
;
const
columns
=
MethodTableConfig
.
getColumns
(
data
&&
data
.
content
?
data
.
content
[
0
]
:
null
);
const
selectedMethod
=
selectedMethodId
&&
data
.
content
.
find
((
method
)
=>
method
.
id
===
selectedMethodId
)
const
actions
=
[
{
...
...
@@ -139,6 +149,7 @@ class BrowsePage extends React.Component<PropsFromRedux & WithTranslation & With
onRowsToggled
=
{
this
.
rowsToggled
}
sort
=
{
data
&&
data
.
sort
}
onSortChange
=
{
onSortChange
}
actions
=
{
{
selectMethod
:
this
.
selectMethod
}
}
/>
{
selected
.
length
>
0
&&
<
FABMenu
...
...
@@ -151,7 +162,7 @@ class BrowsePage extends React.Component<PropsFromRedux & WithTranslation & With
<
AddNewButton
action
=
{
this
.
openMethodDialog
}
/>
}
<
MethodDialog
selectedMethod
=
{
!
createNew
&&
selected
.
length
===
1
&&
data
.
content
.
fi
lter
((
method
)
=>
method
.
id
===
selected
[
0
])
[
0
]
}
selectedMethod
=
{
selectedMethod
??
(
!
createNew
&&
selected
.
length
===
1
&&
data
.
content
.
fi
nd
((
method
)
=>
method
.
id
===
selected
[
0
])
)
}
isOpen
=
{
methodDialogIsOpen
}
onClose
=
{
this
.
closeMethodDialog
}
/>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment