Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
react-admin-cubicweb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cubicweb
react-admin-cubicweb
Commits
1819c3df16ea
Commit
1819c3df16ea
authored
4 years ago
by
Elodie Thiéblin
Browse files
Options
Downloads
Patches
Plain Diff
feat: add Person in demo
parent
bfc15c82519d
No related branches found
No related tags found
No related merge requests found
Pipeline
#40150
passed
4 years ago
Stage: checks
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/demo/src/App.tsx
+85
-0
85 additions, 0 deletions
packages/demo/src/App.tsx
packages/demo/src/schema.ts
+1
-1
1 addition, 1 deletion
packages/demo/src/schema.ts
with
86 additions
and
1 deletion
packages/demo/src/App.tsx
+
85
−
0
View file @
1819c3df
...
@@ -25,6 +25,10 @@
...
@@ -25,6 +25,10 @@
SimpleShowLayout
,
SimpleShowLayout
,
DataProvider
,
DataProvider
,
ReferenceArrayField
,
ReferenceArrayField
,
AutocompleteArrayInput
,
ReferenceArrayInput
,
FunctionField
,
SingleFieldList
,
}
from
"
react-admin
"
;
}
from
"
react-admin
"
;
import
{
client
}
from
"
@logilab/cwclientlibjs
"
;
import
{
client
}
from
"
@logilab/cwclientlibjs
"
;
import
{
createDataProvider
}
from
"
ra-cubicweb/dist
"
;
import
{
createDataProvider
}
from
"
ra-cubicweb/dist
"
;
...
@@ -28,6 +32,7 @@
...
@@ -28,6 +32,7 @@
}
from
"
react-admin
"
;
}
from
"
react-admin
"
;
import
{
client
}
from
"
@logilab/cwclientlibjs
"
;
import
{
client
}
from
"
@logilab/cwclientlibjs
"
;
import
{
createDataProvider
}
from
"
ra-cubicweb/dist
"
;
import
{
createDataProvider
}
from
"
ra-cubicweb/dist
"
;
import
Chip
from
"
@material-ui/core/Chip
"
;
import
{
schema
}
from
"
./schema
"
;
import
{
schema
}
from
"
./schema
"
;
import
{
formHelpers
}
from
"
./formHelpers
"
;
import
{
formHelpers
}
from
"
./formHelpers
"
;
...
@@ -41,6 +46,17 @@
...
@@ -41,6 +46,17 @@
<
ReferenceField
label
=
"City"
link
=
"show"
reference
=
"City"
source
=
"is_in"
>
<
ReferenceField
label
=
"City"
link
=
"show"
reference
=
"City"
source
=
"is_in"
>
<
TextField
source
=
"name"
/>
<
TextField
source
=
"name"
/>
</
ReferenceField
>
</
ReferenceField
>
<
ReferenceArrayField
label
=
"Director"
reference
=
"Person"
source
=
"director"
>
<
SingleFieldList
>
<
FunctionField
<{
id
:
string
;
name
:
string
}
>
render
=
{(
person
)
=>
person
&&
<
Chip
label
=
{
`
${
person
.
name
}
`
}
/>}
/
>
<
/SingleFieldList
>
<
/ReferenceArrayField
>
<
NumberField
source
=
"
longitude
"
/>
<
NumberField
source
=
"
longitude
"
/>
<
NumberField
source
=
"latitude"
/>
<
NumberField
source
=
"latitude"
/>
<
/
SimpleShowLayout
>
<
/
SimpleShowLayout
>
...
@@ -80,6 +96,15 @@
...
@@ -80,6 +96,15 @@
>
>
<
AutocompleteInput
optionText
=
"name"
/>
<
AutocompleteInput
optionText
=
"name"
/>
</
ReferenceInput
>
</
ReferenceInput
>
<
ReferenceArrayInput
label
=
"Director"
source
=
"director"
reference
=
"Person"
sort
=
{
{
field
:
"
name
"
,
order
:
"
ASC
"
}
}
filterToQuery
=
{
(
text
:
string
)
=>
({
name
:
text
})
}
>
<
AutocompleteArrayInput
optionText
=
"name"
/>
</
ReferenceArrayInput
>
</
SimpleForm
>
</
SimpleForm
>
</
Create
>
</
Create
>
);
);
...
@@ -160,6 +185,59 @@
...
@@ -160,6 +185,59 @@
</
Show
>
</
Show
>
);
);
const
PersonList
=
(
props
:
ListProps
)
=>
(
<
List
{
...
props
}
>
<
Datagrid
rowClick
=
"show"
>
<
TextField
source
=
"id"
/>
<
TextField
source
=
"name"
/>
<
TextField
source
=
"email"
/>
</
Datagrid
>
</
List
>
);
const
PersonEdit
=
(
props
:
ListProps
)
=>
{
const
inputProps
=
formHelpers
[
"
Person
"
].
getInputProps
;
return
(
<
Edit
{
...
props
}
>
<
SimpleForm
>
<
TextInput
{
...
inputProps
(
"
name
"
)
}
/>
<
TextInput
{
...
inputProps
(
"
email
"
)
}
/>
</
SimpleForm
>
</
Edit
>
);
};
const
PersonCreate
=
(
props
:
ListProps
)
=>
{
const
inputProps
=
formHelpers
[
"
Person
"
].
getInputProps
;
return
(
<
Create
{
...
props
}
>
<
SimpleForm
>
<
TextInput
{
...
inputProps
(
"
name
"
)
}
/>
<
TextInput
{
...
inputProps
(
"
email
"
)
}
/>
</
SimpleForm
>
</
Create
>
);
};
const
PersonShow
=
(
props
:
ShowProps
)
=>
(
<
Show
{
...
props
}
>
<
SimpleShowLayout
>
<
TextField
source
=
"id"
/>
<
TextField
source
=
"name"
/>
<
TextField
source
=
"email"
/>
<
ReferenceArrayField
label
=
"Museum"
reference
=
"Museum"
source
=
"reverse_director"
>
<
Datagrid
rowClick
=
"show"
>
<
TextField
source
=
"name"
/>
</
Datagrid
>
</
ReferenceArrayField
>
</
SimpleShowLayout
>
</
Show
>
);
const
httpClient
=
new
client
.
CwSimpleHttpClient
(
"
http://localhost:8080
"
,
true
);
const
httpClient
=
new
client
.
CwSimpleHttpClient
(
"
http://localhost:8080
"
,
true
);
const
rqlClient
=
new
client
.
CwRqlClient
(
httpClient
);
const
rqlClient
=
new
client
.
CwRqlClient
(
httpClient
);
...
@@ -186,6 +264,13 @@
...
@@ -186,6 +264,13 @@
edit
=
{
CityEdit
}
edit
=
{
CityEdit
}
create
=
{
CityCreate
}
create
=
{
CityCreate
}
/>
/>
<
Resource
name
=
"Person"
list
=
{
PersonList
}
show
=
{
PersonShow
}
edit
=
{
PersonEdit
}
create
=
{
PersonCreate
}
/>
</
Admin
>
</
Admin
>
);
);
...
...
This diff is collapsed.
Click to expand it.
packages/demo/src/schema.ts
+
1
−
1
View file @
1819c3df
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
country
:
{
type
:
"
String
"
,
default
:
"
France
"
},
country
:
{
type
:
"
String
"
,
default
:
"
France
"
},
},
},
Person
:
{
Person
:
{
name
:
{
type
:
"
String
"
},
name
:
{
type
:
"
String
"
,
required
:
true
},
email
:
{
type
:
"
String
"
},
email
:
{
type
:
"
String
"
},
},
},
},
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment