Skip to content

Commit 15a95bb

Browse files
author
svuillet
committed
Feature #14220
1 parent 2aa6b8d commit 15a95bb

File tree

9 files changed

+238
-18
lines changed

9 files changed

+238
-18
lines changed

mobile-war/src/main/java/org/silverpeas/mobile/client/apps/orgchartgroup/pages/OrgChartGroupPage.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.google.gwt.uibinder.client.UiHandler;
3131
import com.google.gwt.user.client.ui.Widget;
3232
import org.silverpeas.mobile.client.apps.orgchartgroup.pages.widgets.OrgaChartGroupItem;
33+
import org.silverpeas.mobile.client.apps.orgchartgroup.pages.widgets.OrgaChartUserItem;
3334
import org.silverpeas.mobile.client.components.UnorderedList;
3435
import org.silverpeas.mobile.client.components.base.PageContent;
3536
import org.silverpeas.mobile.client.resources.ApplicationMessages;
@@ -50,10 +51,18 @@ public void setData(GroupOrgChartDTO groupOrgChartDTO) {
5051
setTitle(data.getName());
5152
data.getSubGroups().forEach(group -> {
5253
OrgaChartGroupItem item = new OrgaChartGroupItem();
53-
item.setName(group.getName());
54+
item.setData(group);
5455
units.add(item);
5556
});
5657

58+
if (data.getSubGroups().isEmpty()) {
59+
data.getUsers().forEach(user -> {
60+
OrgaChartUserItem item = new OrgaChartUserItem();
61+
item.setData(user);
62+
units.add(item);
63+
});
64+
}
65+
5766
}
5867

5968
interface OrgChartGroupPageUiBinder extends UiBinder<Widget, OrgChartGroupPage> {

mobile-war/src/main/java/org/silverpeas/mobile/client/apps/orgchartgroup/pages/widgets/OrgaChartGroupItem.java

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,42 +41,64 @@
4141
import com.google.gwt.user.client.ui.Widget;
4242
import org.silverpeas.mobile.client.apps.notificationsbox.events.app.NotificationReadenEvent;
4343
import org.silverpeas.mobile.client.apps.notificationsbox.resources.NotificationsMessages;
44+
import org.silverpeas.mobile.client.apps.orgchartgroup.OrgChartGroupApp;
45+
import org.silverpeas.mobile.client.apps.orgchartgroup.pages.OrgChartGroupPage;
4446
import org.silverpeas.mobile.client.apps.orgchartgroup.resources.OrgChartGroupMessages;
4547
import org.silverpeas.mobile.client.common.EventBus;
4648
import org.silverpeas.mobile.client.components.base.widgets.SelectableItem;
49+
import org.silverpeas.mobile.shared.dto.PropertyDTO;
50+
import org.silverpeas.mobile.shared.dto.UserDTO;
4751
import org.silverpeas.mobile.shared.dto.notifications.NotificationBoxDTO;
4852
import org.silverpeas.mobile.shared.dto.notifications.NotificationReceivedDTO;
4953
import org.silverpeas.mobile.shared.dto.notifications.NotificationSendedDTO;
54+
import org.silverpeas.mobile.shared.dto.orgchart.GroupOrgChartDTO;
5055

5156
public class OrgaChartGroupItem extends Composite {
5257

5358
private static OrgChartGroupItemUiBinder uiBinder = GWT.create(OrgChartGroupItemUiBinder.class);
5459

60+
private GroupOrgChartDTO data;
61+
5562
@UiField HTMLPanel container;
5663

5764
@UiField
58-
SpanElement name;
65+
SpanElement name, bossPlace;
5966

6067
@UiField
6168
Anchor link;
6269

6370
@UiField(provided = true) protected OrgChartGroupMessages msg = null;
6471

65-
public void setName(String n) {
66-
name.setInnerText(n);
67-
}
68-
6972

7073
interface OrgChartGroupItemUiBinder extends UiBinder<Widget, OrgaChartGroupItem> {
7174
}
7275

7376
@UiHandler("link")
7477
protected void navigate(ClickEvent event) {
75-
//TODO
78+
OrgChartGroupPage page = new OrgChartGroupPage();
79+
page.setPageTitle(name.getInnerText());
80+
page.setData(data);
81+
page.show();
7682
}
7783

7884
public OrgaChartGroupItem() {
7985
msg = GWT.create(OrgChartGroupMessages.class);
8086
initWidget(uiBinder.createAndBindUi(this));
8187
}
88+
89+
public void setData(GroupOrgChartDTO data) {
90+
this.data = data;
91+
name.setInnerText(data.getName());
92+
String htmlBoss = "";
93+
for (UserDTO boss : data.getBoss()) {
94+
String label = "";
95+
for (PropertyDTO prop : boss.getProperties()) {
96+
if (prop.getKey().equalsIgnoreCase("bossTitle")) {
97+
label = prop.getValue();
98+
}
99+
}
100+
htmlBoss += "<div class='label-boss'>" + label + "</div><div class='boss'><img src='/silverpeas" + boss.getAvatar() + "'></img><span>" + boss.getFirstName() + " " + boss.getLastName() + "</span></div>";
101+
}
102+
bossPlace.setInnerHTML(htmlBoss);
103+
}
82104
}

mobile-war/src/main/java/org/silverpeas/mobile/client/apps/orgchartgroup/pages/widgets/OrgaChartGroupItem.ui.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<g:HTMLPanel tag="li" ui:field="container" styleName="orgachartgroup">
3030
<g:Anchor ui:field="link" styleName="">
3131
<span ui:field="name" class="orgachartgroup-name"></span>
32+
<span ui:field="bossPlace" class="orgachartgroup-boss"></span>
3233
</g:Anchor>
3334
</g:HTMLPanel>
3435

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright (C) 2000 - 2024 Silverpeas
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Affero General Public License as
6+
* published by the Free Software Foundation, either version 3 of the
7+
* License, or (at your option) any later version.
8+
*
9+
* As a special exception to the terms and conditions of version 3.0 of
10+
* the GPL, you may redistribute this Program in connection with Free/Libre
11+
* Open Source Software ("FLOSS") applications as described in Silverpeas's
12+
* FLOSS exception. You should have received a copy of the text describing
13+
* the FLOSS exception, and it is also available here:
14+
* "https://www.silverpeas.org/legal/floss_exception.html"
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Affero General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Affero General Public License
22+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
*/
24+
25+
package org.silverpeas.mobile.client.apps.orgchartgroup.pages.widgets;
26+
27+
import com.google.gwt.core.client.GWT;
28+
import com.google.gwt.dom.client.ImageElement;
29+
import com.google.gwt.dom.client.SpanElement;
30+
import com.google.gwt.event.dom.client.ClickEvent;
31+
import com.google.gwt.uibinder.client.UiBinder;
32+
import com.google.gwt.uibinder.client.UiField;
33+
import com.google.gwt.uibinder.client.UiHandler;
34+
import com.google.gwt.user.client.ui.*;
35+
import org.silverpeas.mobile.client.apps.orgchartgroup.pages.OrgChartGroupPage;
36+
import org.silverpeas.mobile.client.apps.orgchartgroup.resources.OrgChartGroupMessages;
37+
import org.silverpeas.mobile.shared.dto.UserDTO;
38+
import org.silverpeas.mobile.shared.dto.orgchart.GroupOrgChartDTO;
39+
40+
public class OrgaChartUserItem extends Composite {
41+
42+
private static OrgChartUserItemUiBinder uiBinder = GWT.create(OrgChartUserItemUiBinder.class);
43+
44+
private UserDTO data;
45+
46+
@UiField HTMLPanel container;
47+
48+
@UiField
49+
SpanElement name;
50+
51+
@UiField
52+
ImageElement avatar;
53+
54+
@UiField
55+
Anchor link;
56+
57+
@UiField(provided = true) protected OrgChartGroupMessages msg = null;
58+
59+
60+
interface OrgChartUserItemUiBinder extends UiBinder<Widget, OrgaChartUserItem> {
61+
}
62+
63+
@UiHandler("link")
64+
protected void navigate(ClickEvent event) {
65+
//TODO : display profil
66+
}
67+
68+
public OrgaChartUserItem() {
69+
msg = GWT.create(OrgChartGroupMessages.class);
70+
initWidget(uiBinder.createAndBindUi(this));
71+
}
72+
73+
public void setData(UserDTO data) {
74+
this.data = data;
75+
name.setInnerText(data.getFirstName() + " " + data.getLastName());
76+
avatar.setSrc("/silverpeas" + data.getAvatar());
77+
}
78+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!--
2+
~ Copyright (C) 2000 - 2024 Silverpeas
3+
~
4+
~ This program is free software: you can redistribute it and/or modify
5+
~ it under the terms of the GNU Affero General Public License as
6+
~ published by the Free Software Foundation, either version 3 of the
7+
~ License, or (at your option) any later version.
8+
~
9+
~ As a special exception to the terms and conditions of version 3.0 of
10+
~ the GPL, you may redistribute this Program in connection with Free/Libre
11+
~ Open Source Software ("FLOSS") applications as described in Silverpeas's
12+
~ FLOSS exception. You should have received a copy of the text describing
13+
~ the FLOSS exception, and it is also available here:
14+
~ "https://www.silverpeas.org/legal/floss_exception.html"
15+
~
16+
~ This program is distributed in the hope that it will be useful,
17+
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
~ GNU Affero General Public License for more details.
20+
~
21+
~ You should have received a copy of the GNU Affero General Public License
22+
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
-->
24+
25+
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
26+
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui">
27+
<ui:with field='msg' type='org.silverpeas.mobile.client.apps.orgchartgroup.resources.OrgChartGroupMessages'/>
28+
29+
<g:HTMLPanel tag="li" ui:field="container" styleName="orgachartuser">
30+
<g:Anchor ui:field="link" styleName="">
31+
<img src="" ui:field="avatar" class="orgachartuser-avatar"></img>
32+
<span ui:field="name" class="orgachartuser-name"></span>
33+
</g:Anchor>
34+
</g:HTMLPanel>
35+
36+
</ui:UiBinder>

mobile-war/src/main/java/org/silverpeas/mobile/public/spmobile.css

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3535,18 +3535,50 @@ a.popin-btn {
35353535

35363536
/** OrgChartGroup */
35373537

3538-
li.orgachartgroup {
3538+
li.orgachartgroup, li.orgachartuser {
35393539
background-color: var(--white);
35403540
padding: 1em 1em 1em 1em;
35413541
margin-bottom: 1em;
35423542
text-align: center;
35433543
border: 1px solid #e0e0e0;
3544+
margin-left: 2em;
3545+
margin-right: 2em;
3546+
user-select:none;
35443547
}
35453548

3546-
li.orgachartgroup:nth-child(odd) {
3549+
li.orgachartgroup:nth-child(odd), li.orgachartgroup:nth-child(odd)>a {
35473550
background-color: var(--white);
3551+
color: var(--black);
35483552
}
35493553

35503554
li.orgachartgroup:nth-child(even), li.orgachartgroup:nth-child(even)>a {
3551-
background-color: var(--main-bg-color);
3552-
}
3555+
background-color: var(--white);
3556+
color: var(--black);
3557+
}
3558+
3559+
li.orgachartuser:nth-child(odd), li.orgachartuser:nth-child(odd)>a {
3560+
background-color: var(--white);
3561+
color: var(--black);
3562+
}
3563+
3564+
li.orgachartuser:nth-child(even), li.orgachartuser:nth-child(even)>a {
3565+
background-color: var(--white);
3566+
color: var(--black);
3567+
}
3568+
3569+
.orgachartgroup-name {
3570+
display: block;
3571+
margin-bottom: 1em;
3572+
font-size: 1.2em;
3573+
}
3574+
3575+
.orgachartgroup-boss > div.label-boss {
3576+
margin-bottom: 1em;
3577+
}
3578+
3579+
.orgachartuser-avatar, .orgachartgroup-boss > div.boss > img {
3580+
margin-right: 1em;
3581+
width: 3em;
3582+
vertical-align:middle;
3583+
}
3584+

mobile-war/src/main/java/org/silverpeas/mobile/server/services/ServiceOrgChartGroup.java

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.silverpeas.core.web.rs.UserPrivilegeValidation;
3434
import org.silverpeas.core.web.rs.annotation.Authorized;
3535
import org.silverpeas.mobile.shared.dto.GroupDTO;
36+
import org.silverpeas.mobile.shared.dto.PropertyDTO;
3637
import org.silverpeas.mobile.shared.dto.UserDTO;
3738
import org.silverpeas.mobile.shared.dto.orgchart.GroupOrgChartDTO;
3839

@@ -65,26 +66,53 @@ public class ServiceOrgChartGroup extends AbstractRestWebService {
6566
public GroupOrgChartDTO getOrgChart() throws Exception {
6667
ComponentInst app = Administration.get().getComponentInst(componentId);
6768
String groupId = app.getParameterValue("ldapRoot");
69+
String titleField = app.getParameterValue("ldapAttTitle");
70+
String unitsChartCentralLabel = app.getParameterValue("unitsChartCentralLabel");
6871
GroupDetail root = Administration.get().getGroup(groupId);
69-
GroupOrgChartDTO dto = populateOrga(root);
72+
GroupOrgChartDTO dto = populateOrga(root, titleField, unitsChartCentralLabel);
7073
return dto;
7174
}
7275

73-
private GroupOrgChartDTO populateOrga(Group group) {
76+
private GroupOrgChartDTO populateOrga(Group group, String titleField, String unitsChartCentralLabel) throws Exception {
7477
GroupOrgChartDTO dto = new GroupOrgChartDTO();
7578
dto.setId(group.getId());
7679
dto.setName(group.getName());
7780
dto.setName(group.getName());
7881
dto.setId(group.getId());
79-
for (User u : group.getAllUsers()) {
82+
String [] ids = Administration.get().getGroup(group.getId()).getUserIds();
83+
for (String id : ids) {
84+
User u = Administration.get().getUserDetail(id);
8085
dto.addUser(populate(u));
86+
String boss = isBoss(u, titleField, unitsChartCentralLabel);
87+
if (boss != null) {
88+
UserDTO b = populate(u);
89+
PropertyDTO prop = new PropertyDTO();
90+
prop.setKey("bossTitle");
91+
prop.setValue(boss);
92+
b.addProperty(prop);
93+
dto.addBoss(b);
94+
}
8195
}
8296
for (Group g : group.getSubGroups()) {
83-
dto.addSubGroup(populateOrga(g));
97+
dto.addSubGroup(populateOrga(g, titleField, unitsChartCentralLabel));
8498
}
8599
return dto;
86100
}
87101

102+
private String isBoss(User u, String titleField, String unitsChartCentralLabel) throws Exception {
103+
String title = Administration.get().getUserFull(u.getId()).getValue(titleField);
104+
String [] rules = unitsChartCentralLabel.split(";");
105+
for (String rule : rules) {
106+
String [] r = rule.split("=");
107+
r[0] = r[0].trim();
108+
r[1] = r[1].trim();
109+
if (title.contains(r[1])) {
110+
return r[0];
111+
}
112+
}
113+
return null;
114+
}
115+
88116
private UserDTO populate(User user) {
89117
UserDTO dto = new UserDTO();
90118
dto.setId(user.getId());

mobile-war/src/main/java/org/silverpeas/mobile/shared/dto/UserDTO.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import com.fasterxml.jackson.annotation.JsonTypeName;
2828

2929
import java.io.Serializable;
30+
import java.util.ArrayList;
31+
import java.util.List;
3032

3133
@JsonTypeName("UserDTO")
3234
public class UserDTO extends BaseDTO implements Serializable{
@@ -37,6 +39,12 @@ public class UserDTO extends BaseDTO implements Serializable{
3739
private String eMail;
3840
private String firstName;
3941
private String avatar;
42+
private String password;
43+
private List<PropertyDTO> properties = new ArrayList<PropertyDTO>();
44+
45+
public List<PropertyDTO> getProperties() { return properties; }
46+
47+
public void setProperties(List<PropertyDTO> properties) { this.properties = properties; }
4048

4149
public String getLastName() {
4250
return lastName;
@@ -70,6 +78,7 @@ public void setAvatar(String avatar) {
7078
this.avatar = avatar;
7179
}
7280

81+
public void addProperty(PropertyDTO property) { properties.add(property); }
7382

7483
@Override
7584
public boolean equals(Object obj) {

0 commit comments

Comments
 (0)