Skip to content

Commit 5956098

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

13 files changed

+333
-19
lines changed

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

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
11
package org.silverpeas.mobile.client.apps.orgchartgroup;
22

33
import com.google.gwt.core.client.GWT;
4-
import com.google.gwt.user.client.Window;
54
import org.fusesource.restygwt.client.Method;
65
import org.silverpeas.mobile.client.apps.navigation.events.app.external.AbstractNavigationEvent;
76
import org.silverpeas.mobile.client.apps.navigation.events.app.external.NavigationAppInstanceChangedEvent;
87
import org.silverpeas.mobile.client.apps.navigation.events.app.external.NavigationEventHandler;
98
import org.silverpeas.mobile.client.apps.navigation.events.app.external.NavigationShowContentEvent;
9+
import org.silverpeas.mobile.client.apps.orgchartgroup.events.app.AbstractOrgChartGroupAppEvent;
10+
import org.silverpeas.mobile.client.apps.orgchartgroup.events.app.ContactLoadEvent;
11+
import org.silverpeas.mobile.client.apps.orgchartgroup.events.app.OrgChartGroupAppEventHandler;
12+
import org.silverpeas.mobile.client.apps.orgchartgroup.events.ui.ContactLoadedEvent;
1013
import org.silverpeas.mobile.client.apps.orgchartgroup.pages.OrgChartGroupPage;
1114
import org.silverpeas.mobile.client.common.EventBus;
1215
import org.silverpeas.mobile.client.common.ServicesLocator;
1316
import org.silverpeas.mobile.client.common.app.App;
1417
import org.silverpeas.mobile.client.common.network.MethodCallbackOnlineOnly;
1518
import org.silverpeas.mobile.client.resources.ApplicationMessages;
1619
import org.silverpeas.mobile.shared.dto.ContentDTO;
20+
import org.silverpeas.mobile.shared.dto.DetailUserDTO;
1721
import org.silverpeas.mobile.shared.dto.navigation.Apps;
1822
import org.silverpeas.mobile.shared.dto.orgchart.GroupOrgChartDTO;
1923

20-
public class OrgChartGroupApp extends App implements NavigationEventHandler {
24+
public class OrgChartGroupApp extends App implements NavigationEventHandler, OrgChartGroupAppEventHandler {
2125

2226
private ApplicationMessages msg;
2327

2428
public OrgChartGroupApp() {
2529
super();
2630
msg = GWT.create(ApplicationMessages.class);
2731
EventBus.getInstance().addHandler(AbstractNavigationEvent.TYPE, this);
32+
EventBus.getInstance().addHandler(AbstractOrgChartGroupAppEvent.TYPE, this);
2833
}
2934

3035
public void start() {
@@ -69,11 +74,24 @@ public void onSuccess(Method method, GroupOrgChartDTO groupOrgChartDTO) {
6974
}
7075
};
7176
action.attempt();
72-
73-
74-
75-
76-
7777
}
7878
}
79+
80+
@Override
81+
public void loadContact(ContactLoadEvent event) {
82+
MethodCallbackOnlineOnly action = new MethodCallbackOnlineOnly<DetailUserDTO>() {
83+
@Override
84+
public void attempt() {
85+
super.attempt();
86+
ServicesLocator.getServiceContact().getContact(event.getUserId(), this);
87+
}
88+
89+
@Override
90+
public void onSuccess(Method method, DetailUserDTO detailUserDTO) {
91+
super.onSuccess(method, detailUserDTO);
92+
EventBus.getInstance().fireEvent(new ContactLoadedEvent(detailUserDTO));
93+
}
94+
};
95+
action.attempt();
96+
}
7997
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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.events.app;
26+
27+
import com.google.gwt.event.shared.GwtEvent;
28+
29+
public abstract class AbstractOrgChartGroupAppEvent extends GwtEvent<OrgChartGroupAppEventHandler>{
30+
31+
public static Type<OrgChartGroupAppEventHandler> TYPE = new Type<OrgChartGroupAppEventHandler>();
32+
33+
public AbstractOrgChartGroupAppEvent(){
34+
}
35+
36+
@Override
37+
public Type<OrgChartGroupAppEventHandler> getAssociatedType() {
38+
return TYPE;
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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.events.app;
26+
27+
28+
public class ContactLoadEvent extends AbstractOrgChartGroupAppEvent {
29+
30+
private String userId;
31+
32+
public ContactLoadEvent(String userId) {
33+
super();
34+
this.userId = userId;
35+
}
36+
37+
@Override
38+
protected void dispatch(OrgChartGroupAppEventHandler handler) {
39+
handler.loadContact(this);
40+
}
41+
42+
public String getUserId() {
43+
return userId;
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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.events.app;
26+
27+
import com.google.gwt.event.shared.EventHandler;
28+
29+
public interface OrgChartGroupAppEventHandler extends EventHandler{
30+
void loadContact(ContactLoadEvent event);
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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.events.ui;
26+
27+
import com.google.gwt.event.shared.GwtEvent;
28+
29+
public abstract class AbstractOrgChartGroupeUIEvent extends GwtEvent<OrgChartGroupUIEventHandler>{
30+
31+
public static Type<OrgChartGroupUIEventHandler> TYPE = new Type<OrgChartGroupUIEventHandler>();
32+
33+
public AbstractOrgChartGroupeUIEvent(){
34+
}
35+
36+
@Override
37+
public Type<OrgChartGroupUIEventHandler> getAssociatedType() {
38+
return TYPE;
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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.events.ui;
26+
27+
import org.silverpeas.mobile.shared.dto.DetailUserDTO;
28+
29+
30+
public class ContactLoadedEvent extends AbstractOrgChartGroupeUIEvent {
31+
32+
private DetailUserDTO user;
33+
34+
public ContactLoadedEvent(DetailUserDTO user) {
35+
super();
36+
this.user = user;
37+
}
38+
39+
@Override
40+
protected void dispatch(OrgChartGroupUIEventHandler handler) {
41+
handler.onContactLoaded(this);
42+
}
43+
44+
public DetailUserDTO getUser() {
45+
return user;
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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.events.ui;
26+
27+
import com.google.gwt.event.shared.EventHandler;
28+
29+
public interface OrgChartGroupUIEventHandler extends EventHandler{
30+
void onContactLoaded(ContactLoadedEvent event);
31+
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import com.google.gwt.core.client.GWT;
2828
import com.google.gwt.uibinder.client.UiBinder;
2929
import com.google.gwt.uibinder.client.UiField;
30-
import com.google.gwt.uibinder.client.UiHandler;
3130
import com.google.gwt.user.client.ui.Widget;
3231
import org.silverpeas.mobile.client.apps.orgchartgroup.pages.widgets.OrgaChartGroupItem;
3332
import org.silverpeas.mobile.client.apps.orgchartgroup.pages.widgets.OrgaChartUserItem;
@@ -77,6 +76,11 @@ public OrgChartGroupPage() {
7776
@Override
7877
public void stop() {
7978
super.stop();
80-
79+
for (int i = 0; i < units.getCount() ; i++) {
80+
Widget w = units.getWidget(i);
81+
if (w instanceof OrgaChartUserItem) {
82+
((OrgaChartUserItem) w).stop();
83+
}
84+
}
8185
}
8286
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,18 @@ public void setData(GroupOrgChartDTO data) {
9292
String htmlBoss = "";
9393
for (UserDTO boss : data.getBoss()) {
9494
String label = "";
95+
String infos = "<div class='orgachartuser-infos'>";
9596
for (PropertyDTO prop : boss.getProperties()) {
9697
if (prop.getKey().equalsIgnoreCase("bossTitle")) {
9798
label = prop.getValue();
99+
} else {
100+
if (prop.getValue() != null && !prop.getValue().isEmpty()) {
101+
infos += "<div>" + prop.getKey() + " : " + prop.getValue() + "</div>";
102+
}
98103
}
99104
}
100-
htmlBoss += "<div class='label-boss'>" + label + "</div><div class='boss'><img src='/silverpeas" + boss.getAvatar() + "'></img><span>" + boss.getFirstName() + " " + boss.getLastName() + "</span></div>";
105+
infos += "</div>";
106+
htmlBoss += "<div class='label-boss'>" + label + "</div><div class='boss'><img src='/silverpeas" + boss.getAvatar() + "'></img><span>" + boss.getFirstName() + " " + boss.getLastName() + "</span>"+infos+"</div>";
101107
}
102108
bossPlace.setInnerHTML(htmlBoss);
103109
}

0 commit comments

Comments
 (0)