Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
14be9b8
Add layout_group.iteration_type field
xavier-calland Jul 27, 2017
652cac1
Add input for layout_group.iteration_type field
xavier-calland Jul 27, 2017
dabeab9
Disable input for layout_group.iteration_type field if not has_iterat…
xavier-calland Jul 27, 2017
48eaf14
Change iterable layout_group label
xavier-calland Jul 27, 2017
6488031
Add refresh action in ContactList
xavier-calland Aug 4, 2017
1a0ac43
Add ContactList cache in the dashboard
xavier-calland Aug 4, 2017
8ed761d
Hide default refresh button in contact list paging toolbar
xavier-calland Aug 4, 2017
7fa9bde
Improve contact history retrieval requests performance
tbroyer Jul 28, 2017
1a76528
Batch load contact history in ContactListView
xavier-calland Aug 4, 2017
b6c09c4
Improve load of latest history of contacts
xavier-calland Aug 4, 2017
20e4f1b
Improve load of latest history for contact values
xavier-calland Aug 4, 2017
6702f7c
Improve load of Contacts
xavier-calland Aug 4, 2017
7305577
Fix contactModel verification when contactDuplication check
xavier-calland Aug 10, 2017
6c18eae
Add a reference to a checkboxElement in a contactListElement
xavier-calland Aug 9, 2017
400b2ed
Handle checkboxElement reference when saving a contactListElement
xavier-calland Aug 9, 2017
034eb84
Add a parameter on GetContactModels to retrieve all fields
xavier-calland Aug 9, 2017
69ae9ef
Add a combobox to select a checkboxElement when editing a contactList…
xavier-calland Aug 9, 2017
a0a6920
Filter contactListCombobox values if a checkboxElement is defined in …
xavier-calland Aug 9, 2017
02a2acd
Add a maintenance alert in the contact detail page
xavier-calland Aug 7, 2017
77fee41
Update contact model status from READY to USED when creating a contact
xavier-calland Aug 7, 2017
57584bd
Do not propose ContactModel under maintenance when creating a contact
xavier-calland Aug 11, 2017
1e994a3
Handle computation fields in iteration groups
xavier-calland Aug 2, 2017
0c47bdf
Fix copy-pasta and slightly optimize contact list rendering
tbroyer Aug 25, 2017
6663554
Improve contact list field usability
tbroyer Jul 31, 2017
1e8be04
Improve contact list field usability (2)
tbroyer Aug 24, 2017
89e839d
Add Contact export in Frameworks
tdegivry Sep 4, 2017
54aa3b2
Freezing iterative groups for models under maintenance
tdegivry Sep 1, 2017
cc6c30a
Fix contacts list improvements
tdegivry Sep 4, 2017
b9bbc31
Fix : removing Guava use in contact duplication
tdegivry Sep 1, 2017
5eb2f18
Contact search Hibernate request
tdegivry Sep 4, 2017
5e11a03
Improve contact list field usability (3)
tbroyer Aug 25, 2017
7bb1aeb
Creating a label field with a button
tdegivry Sep 6, 2017
3453bf9
Adding withoutUser parameter to contact search
tdegivry Sep 6, 2017
30a7823
Changing contact creation by email popup
tdegivry Sep 6, 2017
22c1cfb
Changing organization combobox in contact details
tdegivry Sep 7, 2017
27c5751
Fix contact loading w/ orgUnits
tdegivry Oct 27, 2017
81e9b5b
Add importation schemes tab to admin of contact models
ftavin Dec 19, 2016
f8ca348
Modify general importation mechanism to include contact imports
ftavin Sep 21, 2017
1694c23
Fix details to please Codacy
ftavin Nov 2, 2017
86f1da6
Handle element with no group in computations
xavier-calland Nov 2, 2017
65a5150
Adding missing organization search in contact list element
tdegivry Sep 22, 2017
68e567b
Add javadoc to Pick function
ftavin Nov 14, 2017
ce776dc
Fixes pull request #106
tdegivry Nov 9, 2017
e80077c
Codacy fixes
ftavin Nov 14, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class ClientValueResolver implements ValueResolver {
* {@inheritDoc}
*/
@Override
public void resolve(final Collection<Dependency> dependencies, final int containerId, final AsyncCallback<Map<Dependency, ComputedValue>> callback) {
public void resolve(final Collection<Dependency> dependencies, final int containerId, final Integer layoutGroupIterationId, final AsyncCallback<Map<Dependency, ComputedValue>> callback) {

final BatchCommand batchCommand = new BatchCommand();
final Map<Command<?>, Dependency> commandToDependencyMap = new HashMap<Command<?>, Dependency>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.sigmah.shared.computation.dependency.Dependency;
import org.sigmah.shared.computation.dependency.SingleDependency;
import org.sigmah.shared.dto.ContactDTO;
import org.sigmah.shared.dto.ContactModelDTO;
import org.sigmah.shared.dto.IsModel;
import org.sigmah.shared.dto.OrgUnitModelDTO;
import org.sigmah.shared.dto.ProjectDTO;
Expand All @@ -64,8 +63,9 @@ public class ComputationTriggerManager {

private final Map<ComputationElementDTO, Computation> computations = new HashMap<ComputationElementDTO, Computation>();
private final Map<FlexibleElementDTO, List<ComputationElementDTO>> dependencies = new HashMap<FlexibleElementDTO, List<ComputationElementDTO>>();
private final Map<FlexibleElementDTO, Field<String>> components = new HashMap<FlexibleElementDTO, Field<String>>();
private final Map<Integer, ComputationElementDTO> elementsWithHandlers = new HashMap<Integer, ComputationElementDTO>();
private final Map<String, Field<String>> components = new HashMap<String, Field<String>>();
private final Map<String, ComputationElementDTO> elementsWithHandlers = new HashMap<String, ComputationElementDTO>();
private final Map<Integer, List<Integer>> iterationsByComputation = new HashMap<Integer, List<Integer>>();

private FlexibleElementContainer container;

Expand Down Expand Up @@ -136,6 +136,7 @@ private void clearMaps() {
this.dependencies.clear();
this.computations.clear();
this.components.clear();
this.iterationsByComputation.clear();
this.elementsWithHandlers.clear();
}

Expand All @@ -152,7 +153,7 @@ private void prepareForComputationElement(final ComputationElementDTO computatio
computations.put(computationElement, computation);

for (final Dependency dependency : computation.getDependencies()) {
List<ComputationElementDTO> list = dependencies.get(dependency);
List<ComputationElementDTO> list = dependencies.get(((SingleDependency) dependency).getFlexibleElement());

if (list == null) {
list = new ArrayList<ComputationElementDTO>();
Expand All @@ -177,7 +178,7 @@ private void prepareForComputationElement(final ComputationElementDTO computatio
* @param modifications
* Value change list.
*/
public void listenToValueChangesOfElement(final FlexibleElementDTO element, final Component component, final List<ValueEvent> modifications) {
public void listenToValueChangesOfElement(final FlexibleElementDTO element, final Component component, final List<ValueEvent> modifications, final Integer iterationId) {

if (component == null) {
Log.trace("Element '" + element.getId() + "' is not accessible by the current user.");
Expand All @@ -192,23 +193,26 @@ public void listenToValueChangesOfElement(final FlexibleElementDTO element, fina
stringField = (StringField) ((HistoryWrapper) component).getField();
}
if (stringField != null) {
components.put(element, stringField);
elementsWithHandlers.put(element.getId(), (ComputationElementDTO) element);
String key = computeKey(iterationId, element);
components.put(key, stringField);
elementsWithHandlers.put(key, (ComputationElementDTO) element);
if (iterationId != null) {
List<Integer> list = iterationsByComputation.get(element.getId());
if (list == null) {
list = new ArrayList<Integer>();
iterationsByComputation.put(element.getId(), list);
}
list.add(iterationId);
}

initialUpdateIfCurrentValueIsEmpty((ComputationElementDTO) element, stringField);
initialUpdateIfCurrentValueIsEmpty((ComputationElementDTO) element, stringField, iterationId);
}
}

final List<ComputationElementDTO> computationElements = dependencies.get(element);

if (computationElements != null) {
element.addValueHandler(new ValueHandler() {

@Override
public void onValueChange(ValueEvent event) {
updateComputations(computationElements, modifications);
}
});
element.addValueHandler(new elementInComputationValueChangeHandler(computationElements, modifications, iterationId));
}
}

Expand All @@ -220,10 +224,10 @@ public void onValueChange(ValueEvent event) {
* @param component
* Component associated to the given element.
*/
private void initialUpdateIfCurrentValueIsEmpty(final ComputationElementDTO computationElement, final Field<String> field) {
private void initialUpdateIfCurrentValueIsEmpty(final ComputationElementDTO computationElement, final Field<String> field, Integer iterationId) {

if (field.getValue() == null || field.getValue().isEmpty()) {
updateComputation(computationElement, new ArrayList<ValueEvent>(), false);
updateComputation(computationElement, new ArrayList<ValueEvent>(), false, iterationId);
}
}

Expand All @@ -235,14 +239,14 @@ private void initialUpdateIfCurrentValueIsEmpty(final ComputationElementDTO comp
* @param modifications
* Value change list.
*/
private void updateComputations(final List<ComputationElementDTO> computationElements, final List<ValueEvent> modifications) {
private void updateComputations(final List<ComputationElementDTO> computationElements, final List<ValueEvent> modifications, Integer iterationId) {

if (computationElements == null) {
return;
}

for (final ComputationElementDTO computationElement : computationElements) {
updateComputation(computationElement, modifications, true);
updateComputation(computationElement, modifications, true, iterationId);
}
}

Expand All @@ -255,24 +259,23 @@ private void updateComputations(final List<ComputationElementDTO> computationEle
* Value change list.
*/
private void updateComputation(final ComputationElementDTO computationElement, final List<ValueEvent> modifications,
final boolean fireEvents) {
final boolean fireEvents, final Integer iterationId) {

final Computation computation = computations.get(computationElement);

final Loadable loadable;

final Field<String> computationView = components.get(computationElement);
final Field<String> computationView = components.get(computeKey(iterationId, computationElement));
if (computationView != null) {
loadable = new LoadingMask(computationView);
} else {
loadable = null;
}

computation.computeValueWithModificationsAndResolver(container, modifications, valueResolver, new SuccessCallback<String>() {
computation.computeValueWithModificationsAndResolver(container, iterationId, modifications, valueResolver, new SuccessCallback<String>() {

@Override
public void onSuccess(String result) {
updateComputationElementWithValue(computationElement, result, modifications, fireEvents);
updateComputationElementWithValue(computationElement, result, modifications, fireEvents, iterationId);
}
}, loadable);
}
Expand All @@ -288,24 +291,28 @@ public void onSuccess(String result) {
* Value change list.
*/
private void updateComputationElementWithValue(final ComputationElementDTO computationElement, final String value,
final List<ValueEvent> modifications, final boolean fireEvents) {
final List<ValueEvent> modifications, final boolean fireEvents, Integer iterationId) {

final Field<String> field = components.get(computationElement);
final Field<String> field = components.get(computeKey(iterationId, computationElement));
if (field != null) {
field.setValue(value);
if (fireEvents) {
fireValueEvent(computationElement, value);
fireValueEvent(computationElement, iterationId, value);
}
} else {
// The affected computation is not displayed.
// Manually adding the value to the modifications.
modifications.add(new ValueEvent(computationElement, value));

// Manually firing the dependencies.
updateComputations(dependencies.get(computationElement), modifications);
updateComputations(dependencies.get(computationElement), modifications, iterationId);
}
}

private String computeKey(Integer iterationId, FlexibleElementDTO element) {
return (iterationId == null ? "" : iterationId) + ":" + element.getId();
}

/**
* Fire a value event for the given computation element.
*
Expand All @@ -314,14 +321,43 @@ private void updateComputationElementWithValue(final ComputationElementDTO compu
* @param value
* New value.
*/
private void fireValueEvent(final ComputationElementDTO computationElement, final String value) {
private void fireValueEvent(final ComputationElementDTO computationElement, Integer iterationId, final String value) {
// Firing a value event to register the change and trigger dependencies update.
final ComputationElementDTO withHandlers = elementsWithHandlers.get(computationElement.getId());
final ComputationElementDTO withHandlers = elementsWithHandlers.get(computeKey(iterationId, computationElement));
if (withHandlers != null) {
withHandlers.fireValueEvent(value);
} else {
computationElement.fireValueEvent(value);
}
}

private class elementInComputationValueChangeHandler implements ValueHandler {

private final List<ComputationElementDTO> computationElements;
private final List<ValueEvent> modifications;
private final Integer iterationId;

public elementInComputationValueChangeHandler(List<ComputationElementDTO> computationElements, List<ValueEvent> modifications, Integer iterationId) {
this.computationElements = computationElements;
this.modifications = modifications;
this.iterationId = iterationId;
}

@Override
public void onValueChange(ValueEvent event) {
updateComputations(computationElements, modifications, iterationId);
if (iterationId == null) {
// Field is not in an iteration -> compute elements in every iteration
for (ComputationElementDTO computationElement : computationElements) {
List<Integer> iterations = iterationsByComputation.get(computationElement.getId());
if (iterations == null) {
continue;
}
for(Integer iteration : iterations) {
updateComputation(computationElement, modifications, true, iteration);
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,13 @@ public void onRowClickEvent(final OrgUnitDTO rowElement) {
view.getOrgUnitsTreeGrid().getDisplayOnlyMainOrgUnitCheckbox().setVisible(false);
} else {
view.getOrgUnitsTreeGrid().getDisplayOnlyMainOrgUnitCheckbox().setValue(true);
view.getOrgUnitsTreeGrid().getDisplayOnlyMainOrgUnitCheckbox().setVisible(true);
view.getOrgUnitsTreeGrid().getDisplayOnlyMainOrgUnitCheckbox().addListener(Events.Change, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent event) {
loadReminders();
loadMonitoredPoints();
loadContacts();
loadContacts(true);
loadProjects(true);
loadOrgUnits();
}
Expand Down Expand Up @@ -276,7 +277,7 @@ public void handleEvent(OfflineEvent event) {
view.getContactsList().getView().refreshToolbar();
enableContact = false;
} else {
loadContacts();
loadContacts(true);
}
view.getContactsList().getView().getAddButton().setEnabled(enableContact);
view.getContactsList().getView().getExportButton().setEnabled(enableContact);
Expand Down Expand Up @@ -304,7 +305,7 @@ public void onPageRequest(final PageRequest request) {
loadOrgUnits();

// Reloads contacts.
loadContacts();
loadContacts(false);

// Reloads projects.
loadProjects(false);
Expand Down Expand Up @@ -525,9 +526,9 @@ public void handleEvent(final ButtonEvent be) {
}
}

private void loadContacts() {
private void loadContacts(boolean forceRefresh) {
if (view.getContactsList() != null) {
view.getContactsList().refresh(view.getOrgUnitsTreeGrid().getDisplayOnlyMainOrgUnitCheckbox().getValue());
view.getContactsList().refresh(view.getOrgUnitsTreeGrid().getDisplayOnlyMainOrgUnitCheckbox().getValue(), forceRefresh);
}
}

Expand Down
Loading