Skip to content

Commit

Permalink
Merge pull request #424 from sinfo/423-allow-team-leaders-to-edit-mem…
Browse files Browse the repository at this point in the history
…bers

Allow Team Leaders to edit members' information
  • Loading branch information
PMax5 authored Jan 31, 2024
2 parents de19ec4 + 0fae7ed commit 1bd6988
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions backend/src/router/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ func InitializeRouter() {
memberRouter.HandleFunc("/{id}", authMember(getMember)).Methods("GET")
memberRouter.HandleFunc("/{id}/role", authMember(getMemberRole)).Methods("GET")
memberRouter.HandleFunc("/{id}/participations", authMember(getMembersParticipations)).Methods("GET")
memberRouter.HandleFunc("/{id}", authAdmin(updateMember)).Methods("PUT")
memberRouter.HandleFunc("/{id}", authTeamLeader(updateMember)).Methods("PUT")
memberRouter.HandleFunc("/{id}", authAdmin(deleteMember)).Methods("DELETE")
memberRouter.HandleFunc("/{id}/image", authCoordinator(setMemberImage)).Methods("POST")
memberRouter.HandleFunc("/{id}/image", authTeamLeader(setMemberImage)).Methods("POST")

// item handlers
itemRouter := r.PathPrefix("/items").Subrouter()
Expand Down
14 changes: 7 additions & 7 deletions frontend/lib/routes/members_teams/member/EditMemberForm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class _EditMemberFormState extends State<EditMemberForm> {

Member me = Provider.of<Member?>(context, listen: false)!;
Member? m;
var role = Provider.of<AuthService>(context, listen: false).role;
var role = await Provider.of<AuthService>(context, listen: false).role;

if (role == Role.ADMIN || role == Role.COORDINATOR) {
if (role == Role.ADMIN || role == Role.COORDINATOR || role == Role.TEAMLEADER) {
m = await _memberService.updateMember(
id: widget.member.id, name: name, istid: istId);
} else {
Expand Down Expand Up @@ -106,15 +106,15 @@ class _EditMemberFormState extends State<EditMemberForm> {
builder: (context, snapshot) {
if (snapshot.hasData) {
Role role = snapshot.data as Role;
var adminOrCoord = role == Role.ADMIN || role == Role.COORDINATOR;
var adminOrCoordOrTeamLeader = role == Role.ADMIN || role == Role.COORDINATOR || role == Role.TEAMLEADER;
return Form(
key: _formKey,
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
readOnly: !adminOrCoord,
readOnly: !adminOrCoordOrTeamLeader,
controller: _nameController,
validator: (value) {
if (value == null || value.isEmpty) {
Expand All @@ -125,14 +125,14 @@ class _EditMemberFormState extends State<EditMemberForm> {
decoration: InputDecoration(
icon: const Icon(Icons.person),
labelText: "Name *",
border: adminOrCoord ? null : InputBorder.none,
border: adminOrCoordOrTeamLeader ? null : InputBorder.none,
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
readOnly: !adminOrCoord,
readOnly: !adminOrCoordOrTeamLeader,
controller: _istIdController,
validator: (value) {
if (value == null || value.isEmpty) {
Expand All @@ -144,7 +144,7 @@ class _EditMemberFormState extends State<EditMemberForm> {
decoration: InputDecoration(
icon: const Icon(Icons.school),
labelText: "IstId *",
border: adminOrCoord ? null : InputBorder.none,
border: adminOrCoordOrTeamLeader ? null : InputBorder.none,
),
),
),
Expand Down

0 comments on commit 1bd6988

Please sign in to comment.