diff --git a/src/main/java/org/sigmah/client/ui/presenter/admin/models/EditLayoutGroupAdminPresenter.java b/src/main/java/org/sigmah/client/ui/presenter/admin/models/EditLayoutGroupAdminPresenter.java index bfaf572a2..5c84b3806 100644 --- a/src/main/java/org/sigmah/client/ui/presenter/admin/models/EditLayoutGroupAdminPresenter.java +++ b/src/main/java/org/sigmah/client/ui/presenter/admin/models/EditLayoutGroupAdminPresenter.java @@ -1,358 +1,356 @@ -package org.sigmah.client.ui.presenter.admin.models; - -/* - * #%L - * Sigmah - * %% - * Copyright (C) 2010 - 2016 URD - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * . - * #L% - */ - -import java.util.HashMap; -import java.util.Map; - -import org.sigmah.client.dispatch.CommandResultHandler; -import org.sigmah.client.event.UpdateEvent; -import org.sigmah.client.i18n.I18N; -import org.sigmah.client.inject.Injector; -import org.sigmah.client.page.Page; -import org.sigmah.client.page.PageRequest; -import org.sigmah.client.page.RequestParameter; -import org.sigmah.client.ui.notif.N10N; -import org.sigmah.client.ui.presenter.base.AbstractPagePresenter; -import org.sigmah.client.ui.presenter.base.HasForm; -import org.sigmah.client.ui.view.admin.models.EditLayoutGroupAdminView; -import org.sigmah.client.ui.view.base.ViewPopupInterface; -import org.sigmah.client.ui.widget.button.Button; -import org.sigmah.client.ui.widget.form.FormPanel; -import org.sigmah.client.util.AdminUtil; -import org.sigmah.client.util.ClientUtils; -import org.sigmah.shared.command.CreateEntity; -import org.sigmah.shared.command.result.CreateResult; -import org.sigmah.shared.dto.IsModel; -import org.sigmah.shared.dto.OrgUnitDetailsDTO; -import org.sigmah.shared.dto.PhaseModelDTO; -import org.sigmah.shared.dto.ProjectDetailsDTO; -import org.sigmah.shared.dto.base.AbstractModelDataEntityDTO; -import org.sigmah.shared.dto.element.FlexibleElementDTO; -import org.sigmah.shared.dto.layout.LayoutDTO; -import org.sigmah.shared.dto.layout.LayoutGroupDTO; - -import com.extjs.gxt.ui.client.data.BaseModelData; -import com.extjs.gxt.ui.client.event.BaseEvent; -import com.extjs.gxt.ui.client.event.ButtonEvent; -import com.extjs.gxt.ui.client.event.Events; -import com.extjs.gxt.ui.client.event.Listener; -import com.extjs.gxt.ui.client.event.SelectionListener; -import com.extjs.gxt.ui.client.widget.form.ComboBox; -import com.extjs.gxt.ui.client.widget.form.Field; -import com.extjs.gxt.ui.client.widget.form.SimpleComboBox; -import com.google.inject.ImplementedBy; -import com.google.inject.Inject; -import com.google.inject.Singleton; +package org.sigmah.client.ui.presenter.admin.models; + +/* + * #%L + * Sigmah + * %% + * Copyright (C) 2010 - 2016 URD + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.sigmah.client.dispatch.CommandResultHandler; +import org.sigmah.client.event.UpdateEvent; +import org.sigmah.client.i18n.I18N; +import org.sigmah.client.inject.Injector; +import org.sigmah.client.page.Page; +import org.sigmah.client.page.PageRequest; +import org.sigmah.client.page.RequestParameter; +import org.sigmah.client.ui.notif.N10N; +import org.sigmah.client.ui.presenter.base.AbstractPagePresenter; +import org.sigmah.client.ui.presenter.base.HasForm; +import org.sigmah.client.ui.view.admin.models.EditLayoutGroupAdminView; +import org.sigmah.client.ui.view.base.ViewPopupInterface; +import org.sigmah.client.ui.widget.button.Button; +import org.sigmah.client.ui.widget.form.FormPanel; +import org.sigmah.client.util.AdminUtil; +import org.sigmah.client.util.ClientUtils; +import org.sigmah.shared.command.CreateEntity; +import org.sigmah.shared.command.result.CreateResult; +import org.sigmah.shared.dto.IsModel; +import org.sigmah.shared.dto.OrgUnitDetailsDTO; +import org.sigmah.shared.dto.PhaseModelDTO; +import org.sigmah.shared.dto.ProjectDetailsDTO; +import org.sigmah.shared.dto.base.AbstractModelDataEntityDTO; +import org.sigmah.shared.dto.layout.LayoutDTO; +import org.sigmah.shared.dto.layout.LayoutGroupDTO; + +import com.extjs.gxt.ui.client.data.BaseModelData; +import com.extjs.gxt.ui.client.event.BaseEvent; +import com.extjs.gxt.ui.client.event.ButtonEvent; +import com.extjs.gxt.ui.client.event.Events; +import com.extjs.gxt.ui.client.event.Listener; +import com.extjs.gxt.ui.client.event.SelectionListener; +import com.extjs.gxt.ui.client.widget.form.ComboBox; +import com.extjs.gxt.ui.client.widget.form.Field; +import com.extjs.gxt.ui.client.widget.form.SimpleComboBox; +import com.google.inject.ImplementedBy; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import java.util.HashSet; +import java.util.List; import org.sigmah.shared.command.Delete; import org.sigmah.shared.command.result.VoidResult; - -/** - * Presenter in charge of creating/editing a layout group. - * - * @author Denis Colliot (dcolliot@ideia.fr) (v2.0) - */ -@Singleton -public class EditLayoutGroupAdminPresenter extends AbstractPagePresenter implements HasForm { - - /** - * Description of the view managed by this presenter. - */ - @ImplementedBy(EditLayoutGroupAdminView.class) - public static interface View extends ViewPopupInterface { - - FormPanel getForm(); - - Field getNameField(); - - ComboBox getContainerField(); - - SimpleComboBox getRowField(); - - Button getSaveButton(); - - Button getDeleteButton(); - - } - - /** - * The edited {@link LayoutGroupDTO}, or {@code null} in case of creation. - */ - private LayoutGroupDTO layoutGroup; - - /** - * Presenter's initialization. - * - * @param view - * The view managed by the presenter. - * @param injector - * The application injector. - */ - @Inject - protected EditLayoutGroupAdminPresenter(final View view, final Injector injector) { - super(view, injector); - } - - /** - * {@inheritDoc} - */ - @Override - public Page getPage() { - return Page.ADMIN_EDIT_LAYOUT_GROUP_MODEL; - } - - /** - * {@inheritDoc} - */ - @Override - public void onBind() { - - // -- - // Container field change events handler. - // -- - - view.getContainerField().addListener(Events.Change, new Listener() { - - @Override - public void handleEvent(final BaseEvent event) { - - final BaseModelData selectedContainer = view.getContainerField().getValue(); - - setRowFieldValues(selectedContainer, null); - } - }); - - // -- - // Save button handler. - // -- - - view.getSaveButton().addSelectionListener(new SelectionListener() { - - @Override - public void componentSelected(final ButtonEvent event) { - onSaveForm(); - } - }); + +/** + * Presenter in charge of creating/editing a layout group. + * + * @author Denis Colliot (dcolliot@ideia.fr) (v2.0) + */ +@Singleton +public class EditLayoutGroupAdminPresenter extends AbstractPagePresenter implements HasForm { + + /** + * Description of the view managed by this presenter. + */ + @ImplementedBy(EditLayoutGroupAdminView.class) + public static interface View extends ViewPopupInterface { + + FormPanel getForm(); + + Field getNameField(); + + ComboBox getContainerField(); + + SimpleComboBox getRowField(); + + Button getSaveButton(); + + Button getDeleteButton(); + + } + + /** + * The edited {@link LayoutGroupDTO}, or {@code null} in case of creation. + */ + private LayoutGroupDTO layoutGroup; + private IsModel currentModel; + + /** + * Presenter's initialization. + * + * @param view The view managed by the presenter. + * @param injector The application injector. + */ + @Inject + protected EditLayoutGroupAdminPresenter(final View view, final Injector injector) { + super(view, injector); + } + + /** + * {@inheritDoc} + */ + @Override + public Page getPage() { + return Page.ADMIN_EDIT_LAYOUT_GROUP_MODEL; + } + + /** + * {@inheritDoc} + */ + @Override + public void onBind() { + + // -- + // Container field change events handler. + // -- + view.getContainerField().addListener(Events.Change, new Listener() { + + @Override + public void handleEvent(final BaseEvent event) { + + final BaseModelData selectedContainer = view.getContainerField().getValue(); + + setRowFieldValues(selectedContainer, null); + } + }); + + // -- + // Save button handler. + // -- + view.getSaveButton().addSelectionListener(new SelectionListener() { + + @Override + public void componentSelected(final ButtonEvent event) { + onSaveForm(); + } + }); // -- - // Delete button handler. + // Delete button handler. + // -- + view.getDeleteButton().addSelectionListener(new SelectionListener() { + + @Override + public void componentSelected(final ButtonEvent event) { + onDelete(); + } + }); + } + + /** + * {@inheritDoc} + */ + @Override + public void onPageRequest(final PageRequest request) { + + view.getForm().clearAll(); + view.getRowField().disable(); + setPageTitle(I18N.CONSTANTS.adminFlexibleGroup()); + layoutGroup = request.getData(RequestParameter.DTO); + currentModel = request.getData(RequestParameter.MODEL); + + if (currentModel == null) { + hideView(); + throw new IllegalArgumentException("Missing required model."); + } + + // -- + // Loads containers. + // -- + + view.getContainerField().getStore().removeAll(); + if (ClientUtils.isNotEmpty(currentModel.getHasLayoutElements())) { + for (final AbstractModelDataEntityDTO hasLayout : currentModel.getHasLayoutElements()) { + if (hasLayout == null) { + continue; + } + view.getContainerField().getStore().add(hasLayout); + } + } + // -- + // Loads the edited element. + // -- + if (layoutGroup != null) { + view.getNameField().setValue(layoutGroup.getTitle()); + view.getContainerField().setValue(layoutGroup.getContainerModel()); + setRowFieldValues(layoutGroup.getContainerModel(), layoutGroup.getRow()); + } else { + layoutGroup = null; + } + } - view.getDeleteButton().addSelectionListener(new SelectionListener() { - - @Override - public void componentSelected(final ButtonEvent event) { - onDelete(); - } - }); - } - - /** - * {@inheritDoc} - */ - @Override - public void onPageRequest(final PageRequest request) { - - view.getForm().clearAll(); - view.getRowField().disable(); - setPageTitle(I18N.CONSTANTS.adminFlexibleGroup()); - - final FlexibleElementDTO flexibleElement = request.getData(RequestParameter.DTO); - final IsModel currentModel = request.getData(RequestParameter.MODEL); - - if (currentModel == null) { - hideView(); - throw new IllegalArgumentException("Missing required model."); - } - - // -- - // Loads containers. - // -- - - view.getContainerField().getStore().removeAll(); - if (ClientUtils.isNotEmpty(currentModel.getHasLayoutElements())) { - for (final AbstractModelDataEntityDTO hasLayout : currentModel.getHasLayoutElements()) { - if (hasLayout == null) { - continue; - } - view.getContainerField().getStore().add(hasLayout); - } - } - - // -- - // Loads the edited element. - // -- - -// view.getDeleteButton().setVisible(flexibleElement != null); - - if (flexibleElement != null) { - layoutGroup = flexibleElement.getGroup(); - - view.getNameField().setValue(layoutGroup.getTitle()); - view.getContainerField().setValue(flexibleElement.getContainerModel()); - setRowFieldValues(flexibleElement.getContainerModel(), layoutGroup.getRow()); - } else { - layoutGroup = null; - } - } - - /** - * {@inheritDoc} - */ - @Override - public FormPanel[] getForms() { - return new FormPanel[] { view.getForm() - }; - } - - // --------------------------------------------------------------------------------------------------------------- - // - // UTILITY METHODS. - // - // --------------------------------------------------------------------------------------------------------------- - - /** - * Populates the row field with the given {@code hasLayout} corresponding layout row counts. - * - * @param hasLayout - * The component with a layout. - * @param selectedValue - * The optional selected value. - */ - private void setRowFieldValues(final BaseModelData hasLayout, final Integer selectedValue) { - - view.getRowField().removeAll(); - view.getRowField().setEnabled(hasLayout != null); - - if (hasLayout == null) { - return; - } - - final LayoutDTO container = getLayout(hasLayout); - - if (container != null) { - view.getRowField().removeAll(); - - for (int i = 0; i < container.getRowsCount(); i++) { - view.getRowField().add(i); - } - - if (layoutGroup == null) { - view.getRowField().add(container.getRowsCount()); - } - } - - view.getRowField().setSimpleValue(selectedValue); - } - - /** - * Retrieves the given {@code hasLayout} corresponding {@link LayoutDTO}. - * - * @param hasLayout - * The container, may be {@code null}. - * @return The given {@code hasLayout} corresponding {@link LayoutDTO}, or {@code null}. - */ - static LayoutDTO getLayout(final BaseModelData hasLayout) { - - if (hasLayout instanceof ProjectDetailsDTO) { - return ((ProjectDetailsDTO) hasLayout).getLayout(); - - } else if (hasLayout instanceof PhaseModelDTO) { - return ((PhaseModelDTO) hasLayout).getLayout(); - - } else if (hasLayout instanceof OrgUnitDetailsDTO) { - return ((OrgUnitDetailsDTO) hasLayout).getLayout(); - - } else { - return null; - } - } - - /** - * Callback executed on save button action. - */ - private void onSaveForm() { - - if (!view.getForm().isValid()) { - return; - } - - final String name = view.getNameField().getValue(); - final Integer row = view.getRowField().getSimpleValue(); - final Integer column = 0; - final LayoutDTO container = getLayout(view.getContainerField().getValue()); - - final LayoutGroupDTO layoutGroupDTO = layoutGroup != null ? layoutGroup : new LayoutGroupDTO(); - layoutGroupDTO.setTitle(name); - layoutGroupDTO.setRow(row); - layoutGroupDTO.setColumn(column); - layoutGroupDTO.setParentLayout(container); - - final Map newGroupProperties = new HashMap(); - newGroupProperties.put(AdminUtil.PROP_NEW_GROUP_LAYOUT, layoutGroupDTO); - - dispatch.execute(new CreateEntity(LayoutGroupDTO.ENTITY_NAME, newGroupProperties), new CommandResultHandler() { - - @Override - public void onCommandFailure(final Throwable caught) { - N10N.error(I18N.CONSTANTS.adminFlexibleGroup(), - I18N.MESSAGES.adminStandardCreationFailure(I18N.MESSAGES.adminStandardLayoutGroup() + " '" + name + "'")); - } - - @Override - public void onCommandSuccess(final CreateResult result) { - - if (result == null) { - N10N.warn(I18N.CONSTANTS.adminFlexibleGroup(), I18N.MESSAGES.adminStandardCreationNull(I18N.MESSAGES.adminStandardLayoutGroup() + " '" + name + "'")); - return; - } - - N10N.infoNotif(I18N.CONSTANTS.adminFlexibleGroup(), - I18N.MESSAGES.adminStandardUpdateSuccess(I18N.MESSAGES.adminStandardLayoutGroup() + " '" + name + "'")); - - hideView(); - - // Send an update event to reload necessary data. - eventBus.fireEvent(new UpdateEvent(UpdateEvent.LAYOUT_GROUP_UPDATE, result.getEntity())); - } - }, view.getSaveButton(), view.getDeleteButton()); - } - - /** - * Callback executed on delete button action. - */ - private void onDelete() { - - dispatch.execute(new Delete(layoutGroup), new CommandResultHandler() { - - @Override - protected void onCommandSuccess(VoidResult result) { - hideView(); + /** + * {@inheritDoc} + */ + @Override + public FormPanel[] getForms() { + return new FormPanel[]{view.getForm() + }; + } + + // --------------------------------------------------------------------------------------------------------------- + // + // UTILITY METHODS. + // + // --------------------------------------------------------------------------------------------------------------- + /** + * Populates the row field with the given {@code hasLayout} corresponding + * layout row counts. + * + * @param hasLayout The component with a layout. + * @param selectedValue The optional selected value. + */ + private void setRowFieldValues(final BaseModelData hasLayout, final Integer selectedValue) { + + view.getRowField().removeAll(); + view.getRowField().setEnabled(hasLayout != null); + + if (hasLayout == null) { + return; + } + + final LayoutDTO container = getLayout(hasLayout); + + if (container != null) { + view.getRowField().removeAll(); + + for (int i = 0; i < container.getRowsCount(); i++) { + view.getRowField().add(i); + } + + if (layoutGroup == null) { + view.getRowField().add(container.getRowsCount()); + } + } + + view.getRowField().setSimpleValue(selectedValue); + } + + /** + * Retrieves the given {@code hasLayout} corresponding {@link LayoutDTO}. + * + * @param hasLayout The container, may be {@code null}. + * @return The given {@code hasLayout} corresponding {@link LayoutDTO}, or + * {@code null}. + */ + static LayoutDTO getLayout(final BaseModelData hasLayout) { + + if (hasLayout instanceof ProjectDetailsDTO) { + return ((ProjectDetailsDTO) hasLayout).getLayout(); + + } else if (hasLayout instanceof PhaseModelDTO) { + return ((PhaseModelDTO) hasLayout).getLayout(); + + } else if (hasLayout instanceof OrgUnitDetailsDTO) { + return ((OrgUnitDetailsDTO) hasLayout).getLayout(); + + } else { + return null; + } + } + + /** + * Callback executed on save button action. + */ + private void onSaveForm() { + + if (!view.getForm().isValid()) { + return; + } + // TODO : fix the unexpected error. + final String name = view.getNameField().getValue(); + final Integer row = view.getRowField().getSimpleValue(); + final Integer column = 0; + final LayoutDTO container = getLayout(view.getContainerField().getValue()); + + final LayoutGroupDTO layoutGroupDTO = layoutGroup != null ? layoutGroup : new LayoutGroupDTO(); + layoutGroupDTO.setTitle(name); + layoutGroupDTO.setRow(row); + layoutGroupDTO.setColumn(column); + layoutGroupDTO.setParentLayout(container); + + final Map newGroupProperties = new HashMap(); + newGroupProperties.put(AdminUtil.PROP_NEW_GROUP_LAYOUT, layoutGroupDTO); + + dispatch.execute(new CreateEntity(LayoutGroupDTO.ENTITY_NAME, newGroupProperties), new CommandResultHandler() { + + @Override + public void onCommandFailure(final Throwable caught) { + N10N.error(I18N.CONSTANTS.adminFlexibleGroup(), + I18N.MESSAGES.adminStandardCreationFailure(I18N.MESSAGES.adminStandardLayoutGroup() + " '" + name + "'")); + } + + @Override + public void onCommandSuccess(final CreateResult result) { + + if (result == null) { + N10N.warn(I18N.CONSTANTS.adminFlexibleGroup(), I18N.MESSAGES.adminStandardCreationNull(I18N.MESSAGES.adminStandardLayoutGroup() + " '" + name + "'")); + return; + } + final LayoutGroupDTO lg = (LayoutGroupDTO) result.getEntity(); + if (layoutGroup != null) { + // Update case. + N10N.infoNotif(I18N.CONSTANTS.adminPhaseCreationBox(), + I18N.MESSAGES.adminStandardUpdateSuccessF(I18N.MESSAGES.adminStandardLayoutGroup() + " '" + name + "'")); + + } else { + // Creation case. + N10N.infoNotif(I18N.CONSTANTS.adminPhaseCreationBox(), + I18N.MESSAGES.adminStandardCreationSuccessF(I18N.MESSAGES.adminStandardLayoutGroup() + " '" + name + "'")); + } + hideView(); + + // Send an update event to reload necessary data. + eventBus.fireEvent(new UpdateEvent(UpdateEvent.LAYOUT_GROUP_UPDATE, lg)); + } + }, view.getSaveButton(), view.getDeleteButton()); + + } + + /** + * Callback executed on delete button action. + */ + private void onDelete() { + + dispatch.execute(new Delete(layoutGroup), new CommandResultHandler() { + + @Override + protected void onCommandSuccess(VoidResult result) { + hideView(); // Send an update event to reload necessary data. - // eventBus.fireEvent(new UpdateEvent(UpdateEvent.LAYOUT_GROUP_UPDATE, result.getEntity())); - } - }, view.getSaveButton(), view.getDeleteButton()); - } - -} + // eventBus.fireEvent(new UpdateEvent(UpdateEvent.LAYOUT_GROUP_UPDATE, result.getEntity())); + } + }, view.getSaveButton(), view.getDeleteButton()); + } + +} diff --git a/src/main/java/org/sigmah/client/ui/presenter/admin/models/LayoutGroupAdminPresenter.java b/src/main/java/org/sigmah/client/ui/presenter/admin/models/LayoutGroupAdminPresenter.java new file mode 100644 index 000000000..786ac7cbe --- /dev/null +++ b/src/main/java/org/sigmah/client/ui/presenter/admin/models/LayoutGroupAdminPresenter.java @@ -0,0 +1,266 @@ +package org.sigmah.client.ui.presenter.admin.models; + +/* + * #%L + * Sigmah + * %% + * Copyright (C) 2010 - 2016 URD + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ +import java.util.ArrayList; +import java.util.List; + +import org.sigmah.client.dispatch.CommandResultHandler; +import org.sigmah.client.event.UpdateEvent; +import org.sigmah.client.event.handler.UpdateHandler; +import org.sigmah.client.i18n.I18N; +import org.sigmah.client.inject.Injector; +import org.sigmah.client.page.Page; +import org.sigmah.client.page.RequestParameter; +import org.sigmah.client.ui.notif.ConfirmCallback; +import org.sigmah.client.ui.notif.N10N; +import org.sigmah.client.ui.presenter.admin.models.base.IsModelTabPresenter; +import org.sigmah.client.ui.presenter.base.AbstractPresenter; +import org.sigmah.client.ui.view.base.ViewInterface; +import org.sigmah.client.ui.widget.HasGrid; +import org.sigmah.client.ui.widget.HasGrid.GridEventHandler; +import org.sigmah.client.ui.widget.button.Button; +import org.sigmah.client.util.ClientUtils; +import org.sigmah.shared.command.result.VoidResult; +import org.sigmah.shared.dto.IsModel; +import org.sigmah.client.ui.view.admin.models.LayoutGroupAdminView; +import org.sigmah.shared.dto.layout.LayoutGroupDTO; +import org.sigmah.shared.command.DeleteGroups; + +import com.extjs.gxt.ui.client.event.ButtonEvent; +import com.extjs.gxt.ui.client.event.SelectionChangedEvent; +import com.extjs.gxt.ui.client.event.SelectionChangedListener; +import com.extjs.gxt.ui.client.event.SelectionListener; +import com.google.inject.ImplementedBy; +import com.google.inject.Inject; + +/** + * Model's layout groups administration presenter. + * + * @author Nikita Jibhkate (niksj1996@gmail.com) + */ + +public class LayoutGroupAdminPresenter extends + AbstractPresenter + implements IsModelTabPresenter { + + /** + * Description of the view managed by this presenter. + */ + @ImplementedBy(LayoutGroupAdminView.class) + public static interface View extends ViewInterface, HasGrid { + + void setModelEditable(final boolean editable); + + void setToolbarEnabled(boolean enabled); + + Button getAddButton(); + + Button getDeleteButton(); + + } + + // The current model. + private E currentModel; + + /** + * Presenter's initialization. + * + * @param view The view managed by this presenter. + * @param injector The application injector. + */ + @Inject + public LayoutGroupAdminPresenter(final View view, final Injector injector) { + super(view, injector); + } + + /** + * {@inheritDoc} + */ + @Override + public void onBind() { + + // -- + // Grid selection change handler. + // -- + view.getGrid().getSelectionModel().addSelectionChangedListener(new SelectionChangedListener() { + + @Override + public void selectionChanged(final SelectionChangedEvent event) { + final boolean enabled = ClientUtils.isNotEmpty(event.getSelection()); + + view.getDeleteButton().setEnabled(enabled); + } + }); + + // Grid events handler + view.setGridEventHandler(new GridEventHandler() { + + @Override + public void onRowClickEvent(final LayoutGroupDTO rowElement) { + + eventBus.navigateRequest(Page.ADMIN_EDIT_LAYOUT_GROUP_MODEL.request().addData(RequestParameter.MODEL, currentModel) + .addData(RequestParameter.DTO, rowElement)); + } + }); + + // Add button handler + view.getAddButton().addSelectionListener(new SelectionListener() { + + @Override + public void componentSelected(final ButtonEvent ce) { + eventBus.navigateRequest(Page.ADMIN_EDIT_LAYOUT_GROUP_MODEL.request().addData(RequestParameter.MODEL, currentModel)); + } + }); + + // Delete button handler + view.getDeleteButton().addSelectionListener(new SelectionListener() { + + @Override + public void componentSelected(final ButtonEvent event) { + onGroupsDeleteAction(view.getGrid().getSelectionModel().getSelection()); + } + }); + + // On groups creation/update event. + registerHandler(eventBus.addHandler(UpdateEvent.getType(), new UpdateHandler() { + + @Override + public void onUpdate(final UpdateEvent event) { + + if (event.concern(UpdateEvent.LAYOUT_GROUP_UPDATE)) { + + final boolean update = event.getParam(1); + final LayoutGroupDTO updatedOrCreatedElement = event.getParam(2); + onGroupsUpdate(update, updatedOrCreatedElement); + } + + } + })); + } + + /** + * {@inheritDoc} + */ + @Override + public String getTabTitle() { + return I18N.CONSTANTS.adminProjectModelGroups(); + } + + /** + * {@inheritDoc} + */ + @Override + public void loadTab(final E model) { + + this.currentModel = model; + view.setModelEditable(model.isEditable()); + view.setToolbarEnabled(model.getStatus() != null && model.isEditable()); + view.getDeleteButton().setVisible(!model.isUnderMaintenance()); + + view.getStore().removeAll(); + view.getStore().add(model.getAllGroups()); + view.getStore().commitChanges(); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean hasValueChanged() { + return false; + } + + // --------------------------------------------------------------------------------------------------------------- + // + // UTILITY METHODS. + // + // --------------------------------------------------------------------------------------------------------------- + /** + * Callback executed on delete button action. + * + * @param groups The selected group to delete. + */ + private void onGroupsUpdate(final boolean udpate, final LayoutGroupDTO updatedOrCreatedElement) { + + if (udpate) { + view.getStore().update(updatedOrCreatedElement); + + } else { + view.getStore().add(updatedOrCreatedElement); + } + + view.getStore().commitChanges(); + } + + private void onGroupsDeleteAction(final List selection) { + + if (ClientUtils.isEmpty(selection)) { + N10N.warn(I18N.CONSTANTS.delete(), I18N.MESSAGES.adminGroupsDeleteNone()); + return; + } + + final List elementNames = new ArrayList(); + + for (final LayoutGroupDTO element : selection) { + elementNames.add(element.getTitle()); + } + + N10N.confirmation(I18N.CONSTANTS.delete(), I18N.CONSTANTS.adminGroupsConfirmDelete(), elementNames, new ConfirmCallback() { + + @Override + public void onAction() { + + dispatch.execute(new DeleteGroups(selection), new CommandResultHandler() { + + @Override + public void onCommandFailure(final Throwable caught) { + + final StringBuilder builder = new StringBuilder(); + for (final String deleted : elementNames) { + if (builder.length() > 0) { + builder.append(", "); + } + builder.append(deleted); + } + + N10N.warn(I18N.CONSTANTS.error(), I18N.MESSAGES.entityDeleteEventError(builder.toString())); + } + + @Override + public void onCommandSuccess(final VoidResult result) { + + // Updates the store. + for (final LayoutGroupDTO element : selection) { + view.getStore().remove(element); + } + + // Notification. + N10N.infoNotif(I18N.CONSTANTS.infoConfirmation(), I18N.CONSTANTS.adminDeleteLayoutGroupsConfirm()); + + } + }); + } + }); + } + +} diff --git a/src/main/java/org/sigmah/client/ui/presenter/admin/models/orgunit/OrgUnitModelsAdminPresenter.java b/src/main/java/org/sigmah/client/ui/presenter/admin/models/orgunit/OrgUnitModelsAdminPresenter.java index d23e80843..bfd7cb352 100644 --- a/src/main/java/org/sigmah/client/ui/presenter/admin/models/orgunit/OrgUnitModelsAdminPresenter.java +++ b/src/main/java/org/sigmah/client/ui/presenter/admin/models/orgunit/OrgUnitModelsAdminPresenter.java @@ -1,27 +1,27 @@ -package org.sigmah.client.ui.presenter.admin.models.orgunit; - -/* - * #%L - * Sigmah - * %% - * Copyright (C) 2010 - 2016 URD - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * . - * #L% - */ - +package org.sigmah.client.ui.presenter.admin.models.orgunit; + +/* + * #%L + * Sigmah + * %% + * Copyright (C) 2010 - 2016 URD + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ + import java.util.HashMap; import java.util.Map; @@ -37,6 +37,7 @@ import org.sigmah.client.ui.presenter.admin.models.FlexibleElementsAdminPresenter; import org.sigmah.client.ui.presenter.admin.models.base.AbstractModelsAdminPresenter; import org.sigmah.client.ui.presenter.admin.models.importer.ImportationSchemeModelsAdminPresenter; +import org.sigmah.client.ui.presenter.admin.models.LayoutGroupAdminPresenter; import org.sigmah.client.ui.view.admin.models.orgunit.OrgUnitModelsAdminView; import org.sigmah.client.util.AdminUtil; import org.sigmah.client.util.EnumModel; @@ -91,12 +92,15 @@ public static interface View extends AbstractModelsAdminPresenter.View> flexibleElementsProvider, final Provider> importationSchemeModelsAdminPresenterProvider) { - super(view, injector, flexibleElementsProvider.get(), importationSchemeModelsAdminPresenterProvider.get()); - } - + protected OrgUnitModelsAdminPresenter(final View view, final Injector injector, final Provider> flexibleElementsProvider, final Provider> layoutGroupAdminPresenterProvider, final Provider> importationSchemeModelsAdminPresenterProvider) { + super(view, injector, flexibleElementsProvider.get(), layoutGroupAdminPresenterProvider.get(), importationSchemeModelsAdminPresenterProvider.get()); + } /** * {@inheritDoc} */ diff --git a/src/main/java/org/sigmah/client/ui/presenter/admin/models/project/ProjectModelsAdminPresenter.java b/src/main/java/org/sigmah/client/ui/presenter/admin/models/project/ProjectModelsAdminPresenter.java index 2a1b15c20..6122f48cd 100644 --- a/src/main/java/org/sigmah/client/ui/presenter/admin/models/project/ProjectModelsAdminPresenter.java +++ b/src/main/java/org/sigmah/client/ui/presenter/admin/models/project/ProjectModelsAdminPresenter.java @@ -37,6 +37,7 @@ import org.sigmah.client.ui.presenter.admin.models.FlexibleElementsAdminPresenter; import org.sigmah.client.ui.presenter.admin.models.base.AbstractModelsAdminPresenter; import org.sigmah.client.ui.presenter.admin.models.importer.ImportationSchemeModelsAdminPresenter; +import org.sigmah.client.ui.presenter.admin.models.LayoutGroupAdminPresenter; import org.sigmah.client.ui.view.admin.models.project.ProjectModelsAdminView; import org.sigmah.client.ui.widget.form.ListComboBox; import org.sigmah.client.util.AdminUtil; @@ -97,14 +98,16 @@ public static interface ProjectTypeProvider { /** * Presenters's initialization. - * + * * @param view * Presenter's view interface. * @param injector * Injected client injector. * @param flexibleElementsProvider * The {@link FlexibleElementsAdminPresenter} provider. - * @param phaseModelsAdminPresenterProvider + * @param layoutGroupAdminPresenterProvider + * The {@link LayoutGroupAdminPresenter} provider. + * @param phaseModelsAdminPresenterProvider * The {@link PhaseModelsAdminPresenter} provider. * @param logFrameModelsAdminPresenterProvider * The {@link LogFrameModelsAdminPresenter} provider. @@ -112,11 +115,10 @@ public static interface ProjectTypeProvider { * The {@link ImportationSchemeModelsAdminPresenter} provider. */ @Inject - protected ProjectModelsAdminPresenter(final View view, final Injector injector, final Provider> flexibleElementsProvider, final Provider phaseModelsAdminPresenterProvider, final Provider logFrameModelsAdminPresenterProvider, final Provider> importationSchemeModelsAdminPresenterProvider) { - super(view, injector, flexibleElementsProvider.get(), phaseModelsAdminPresenterProvider.get(), logFrameModelsAdminPresenterProvider.get(), - importationSchemeModelsAdminPresenterProvider.get()); + protected ProjectModelsAdminPresenter(final View view, final Injector injector, final Provider> flexibleElementsProvider, final Provider> layoutGroupAdminPresenterProvider, final Provider phaseModelsAdminPresenterProvider, final Provider logFrameModelsAdminPresenterProvider, final Provider> importationSchemeModelsAdminPresenterProvider) { + super(view, injector, flexibleElementsProvider.get(), layoutGroupAdminPresenterProvider.get(), phaseModelsAdminPresenterProvider.get(), logFrameModelsAdminPresenterProvider.get(), + importationSchemeModelsAdminPresenterProvider.get()); } - /** * {@inheritDoc} */ diff --git a/src/main/java/org/sigmah/client/ui/view/admin/models/LayoutGroupAdminView.java b/src/main/java/org/sigmah/client/ui/view/admin/models/LayoutGroupAdminView.java new file mode 100644 index 000000000..91eb98b08 --- /dev/null +++ b/src/main/java/org/sigmah/client/ui/view/admin/models/LayoutGroupAdminView.java @@ -0,0 +1,186 @@ +package org.sigmah.client.ui.view.admin.models; + +/* + * #%L + * Sigmah + * %% + * Copyright (C) 2010 - 2016 URD + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ +import org.sigmah.client.i18n.I18N; +import org.sigmah.client.ui.presenter.admin.models.LayoutGroupAdminPresenter; +import org.sigmah.client.ui.res.icon.IconImageBundle; +import org.sigmah.client.ui.view.base.AbstractView; +import org.sigmah.client.ui.widget.button.Button; +import org.sigmah.client.ui.widget.form.Forms; +import org.sigmah.client.ui.widget.panel.Panels; +import org.sigmah.shared.dto.layout.LayoutGroupDTO; + +import com.extjs.gxt.ui.client.Style.SelectionMode; +import com.extjs.gxt.ui.client.store.ListStore; +import com.extjs.gxt.ui.client.widget.Component; +import com.extjs.gxt.ui.client.widget.ContentPanel; +import com.extjs.gxt.ui.client.widget.grid.Grid; +import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel; +import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; + +/** + * {@link LayoutGroupAdminPresenter}'s view implementation. + * + * @author Nikita Jibhkate (niksj1996@gmail.com) + */ + +public class LayoutGroupAdminView extends AbstractView implements LayoutGroupAdminPresenter.View { + + private Grid grid; + private ToolBar toolbar; + private Button addButton; + private Button deleteButton; + private boolean editable; + private GridEventHandler gridEventHandler; + + /** + * {@inheritDoc} + */ + @Override + public void initialize() { + + final ContentPanel mainPanel = Panels.content(null); + + mainPanel.add(createGrid()); + mainPanel.setTopComponent(createToolBar()); + + add(mainPanel); + } + + /** + * {@inheritDoc} + */ + @Override + public Grid getGrid() { + return grid; + } + + /** + * {@inheritDoc} + */ + @Override + public ListStore getStore() { + return grid.getStore(); + } + + /** + * {@inheritDoc} + */ + @Override + public void setGridEventHandler(final GridEventHandler handler) { + this.gridEventHandler = handler; + } + + @Override + public void setModelEditable(final boolean editable) { + this.editable = editable; + } + + /** + * {@inheritDoc} + */ + @Override + public Button getAddButton() { + return addButton; + } + + /** + * {@inheritDoc} + */ + @Override + public Button getDeleteButton() { + return deleteButton; + } + + /** + * {@inheritDoc} + */ + @Override + public void setToolbarEnabled(final boolean enabled) { + if (enabled) { + toolbar.show(); + } else { + toolbar.hide(); + } + toolbar.setEnabled(enabled); + addButton.setEnabled(enabled); + deleteButton.setEnabled(false); + } + + // --------------------------------------------------------------------------------------------------------------- + // + // UTILITY METHODS. + // + // --------------------------------------------------------------------------------------------------------------- + /** + * Creates the grid component. + * + * @return The grid component. + */ + private Component createGrid() { + + grid = new Grid(new ListStore(), new LayoutGroupColumnsProvider() { + + @Override + protected boolean isEditable() { + return editable; + } + + @Override + protected GridEventHandler getGridEventHandler() { + return gridEventHandler; + } + + }.getColumnModel()); + + grid.setAutoHeight(true); + grid.getView().setForceFit(true); + grid.getStore().setSortField(LayoutGroupDTO.ROW); + + final GridSelectionModel selectionModel = new GridSelectionModel(); + selectionModel.setSelectionMode(SelectionMode.MULTI); + grid.setSelectionModel(selectionModel); + + return grid; + } + + /** + * Creates the toolbar component and its buttons. + * + * @return The toolbar component. + */ + private Component createToolBar() { + + toolbar = new ToolBar(); + + addButton = Forms.button(I18N.CONSTANTS.addItem(), IconImageBundle.ICONS.add()); + toolbar.add(addButton); + + deleteButton = Forms.button(I18N.CONSTANTS.delete(), IconImageBundle.ICONS.delete()); + deleteButton.disable(); + toolbar.add(deleteButton); + + return toolbar; + } + +} diff --git a/src/main/java/org/sigmah/client/ui/view/admin/models/LayoutGroupColumnsProvider.java b/src/main/java/org/sigmah/client/ui/view/admin/models/LayoutGroupColumnsProvider.java new file mode 100644 index 000000000..35ef049e7 --- /dev/null +++ b/src/main/java/org/sigmah/client/ui/view/admin/models/LayoutGroupColumnsProvider.java @@ -0,0 +1,131 @@ +package org.sigmah.client.ui.view.admin.models; + +/* + * #%L + * Sigmah + * %% + * Copyright (C) 2010 - 2016 URD + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ +import java.util.ArrayList; +import java.util.List; + +import org.sigmah.client.i18n.I18N; +import org.sigmah.client.ui.widget.HasGrid.GridEventHandler; +import org.sigmah.client.util.ColumnProviders; +import org.sigmah.shared.dto.layout.LayoutGroupDTO; + +import com.extjs.gxt.ui.client.data.BaseModelData; +import com.extjs.gxt.ui.client.store.ListStore; +import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; +import com.extjs.gxt.ui.client.widget.grid.ColumnData; +import com.extjs.gxt.ui.client.widget.grid.ColumnModel; +import com.extjs.gxt.ui.client.widget.grid.Grid; +import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; + +/** + * Provides layout groups admin grid columns configuration. + * + * @author Nikita Jibhkate (niksj1996@gmail.com) + */ +abstract class LayoutGroupColumnsProvider { + + /** + * Returns true if the parent model is editable. + * + * @return true if the parent model is editable, + * false otherwise. + */ + protected abstract boolean isEditable(); + + /** + * Returns the {@link GridEventHandler} implementation. + * + * @return The {@link GridEventHandler} implementation. + */ + protected abstract GridEventHandler getGridEventHandler(); + + /** + * Gets the columns model for the flexible elements admin grid. + * + * @return The columns model for the flexible elements admin grid. + */ + public ColumnModel getColumnModel() { + + final List configs = new ArrayList(); + + // -- + // Group Name column. + // -- + ColumnConfig column = new ColumnConfig(LayoutGroupDTO.TITLE, I18N.CONSTANTS.adminFlexibleName(), 180); + column.setRenderer(new GridCellRenderer() { + + @Override + public Object render(final LayoutGroupDTO model, final String property, final ColumnData config, final int rowIndex, final int colIndex, + final ListStore store, final Grid grid) { + + return ColumnProviders.renderLink(model.getTitle(), new ClickHandler() { + + @Override + public void onClick(final ClickEvent event) { + + getGridEventHandler().onRowClickEvent(model); + + } + + }); + } + }); + configs.add(column); + + // -- + // Containers column. + // -- + column = new ColumnConfig(LayoutGroupDTO.CONTAINER, I18N.CONSTANTS.adminFlexibleContainer(), 150); + column.setRenderer(new GridCellRenderer() { + + @Override + public Object render(final LayoutGroupDTO model, final String property, final ColumnData config, final int rowIndex, final int colIndex, + final ListStore store, final Grid grid) { + + final BaseModelData container = model.getContainerModel(); + return ColumnProviders.renderText(container.get("name")); + } + + }); + configs.add(column); + // -- + // Position column. + // -- + + column = new ColumnConfig("position", I18N.CONSTANTS.adminGroupsPosition(), 70); + column.setRenderer(new GridCellRenderer() { + + @Override + public Object render(final LayoutGroupDTO model, final String property, final ColumnData config, final int rowIndex, final int colIndex, + final ListStore store, final Grid grid) { + + return ColumnProviders.renderText(model.getRow()); + } + }); + configs.add(column); + return new ColumnModel(configs); + } + +} diff --git a/src/main/java/org/sigmah/client/util/AdminUtil.java b/src/main/java/org/sigmah/client/util/AdminUtil.java index bb103f60d..4b0c0cb3d 100644 --- a/src/main/java/org/sigmah/client/util/AdminUtil.java +++ b/src/main/java/org/sigmah/client/util/AdminUtil.java @@ -101,6 +101,8 @@ public final class AdminUtil { public static final String PROP_FX_OLD_FIELDS = "oldFieldProperties"; public static final String PROP_NEW_GROUP_LAYOUT = "NewLayoutGroup"; + public static final String PROP_GROUP_CONTAINER = "Container"; + public static final String PROP_GROUP_POSITION = "Position"; public static final String PROP_PHASE_MODEL = "NewPhaseModel"; public static final String PROP_PHASE_ROWS = "PhaseRows"; diff --git a/src/main/java/org/sigmah/server/domain/layout/LayoutGroup.java b/src/main/java/org/sigmah/server/domain/layout/LayoutGroup.java index 64dad8dcc..0080bf5bf 100644 --- a/src/main/java/org/sigmah/server/domain/layout/LayoutGroup.java +++ b/src/main/java/org/sigmah/server/domain/layout/LayoutGroup.java @@ -1,28 +1,26 @@ -package org.sigmah.server.domain.layout; - -/* - * #%L - * Sigmah - * %% - * Copyright (C) 2010 - 2016 URD - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * . - * #L% - */ - - +package org.sigmah.server.domain.layout; + +/* + * #%L + * Sigmah + * %% + * Copyright (C) 2010 - 2016 URD + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ import java.util.ArrayList; import java.util.List; @@ -48,160 +46,155 @@ *

* Layout Group domain entity. *

- * + * * @author Denis Colliot (dcolliot@ideia.fr) */ @Entity @Table(name = EntityConstants.LAYOUT_GROUP_TABLE) public class LayoutGroup extends AbstractEntityId { - /** - * Serial version UID. - */ - private static final long serialVersionUID = -5138315416849070907L; + /** + * Serial version UID. + */ + private static final long serialVersionUID = -5138315416849070907L; - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = EntityConstants.LAYOUT_GROUP_COLUMN_ID) - private Integer id; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = EntityConstants.LAYOUT_GROUP_COLUMN_ID) + private Integer id; - @Column(name = EntityConstants.LAYOUT_GROUP_COLUMN_ROW_INDEX, nullable = false) - @NotNull - private Integer row; + @Column(name = EntityConstants.LAYOUT_GROUP_COLUMN_ROW_INDEX, nullable = false) + @NotNull + private Integer row; - @Column(name = EntityConstants.LAYOUT_GROUP_COLUMN_COLUMN_INDEX, nullable = false) - @NotNull - private Integer column; + @Column(name = EntityConstants.LAYOUT_GROUP_COLUMN_COLUMN_INDEX, nullable = false) + @NotNull + private Integer column; - @Column(name = EntityConstants.LAYOUT_GROUP_COLUMN_TITLE, nullable = true, length = EntityConstants.LAYOUT_GROUP_TITLE_MAX_LENGTH) - @Size(max = EntityConstants.LAYOUT_GROUP_TITLE_MAX_LENGTH) - private String title; + @Column(name = EntityConstants.LAYOUT_GROUP_COLUMN_TITLE, nullable = true, length = EntityConstants.LAYOUT_GROUP_TITLE_MAX_LENGTH) + @Size(max = EntityConstants.LAYOUT_GROUP_TITLE_MAX_LENGTH) + private String title; // -------------------------------------------------------------------------------- - // - // FOREIGN KEYS. - // - // -------------------------------------------------------------------------------- + // + // FOREIGN KEYS. + // + // -------------------------------------------------------------------------------- + @ManyToOne(optional = false) + @JoinColumn(name = EntityConstants.LAYOUT_COLUMN_ID, nullable = false) + @NotNull + private Layout parentLayout; + + @OneToMany(mappedBy = "parentLayoutGroup", cascade = CascadeType.ALL) + @OrderBy("sortOrder ASC, id ASC") + private List constraints = new ArrayList(); - @ManyToOne(optional = false) - @JoinColumn(name = EntityConstants.LAYOUT_COLUMN_ID, nullable = false) - @NotNull - private Layout parentLayout; - - @OneToMany(mappedBy = "parentLayoutGroup", cascade = CascadeType.ALL) - @OrderBy("sortOrder ASC, id ASC") - private List constraints = new ArrayList(); - - // -------------------------------------------------------------------------------- - // - // METHODS. - // // -------------------------------------------------------------------------------- + // + // METHODS. + // + // -------------------------------------------------------------------------------- + public LayoutGroup() { + } + + /** + * Adds a constraint to the current layout group if it is not null. + * + * @param constraint The constraint to add. + */ + public void addConstraint(LayoutConstraint constraint) { + + if (constraint == null) { + return; + } + + constraint.setParentLayoutGroup(this); + constraints.add(constraint); + } + + /** + * Reset the identifiers of the object. + * + * @param parentLayout the parent Layout + * @param keepPrivacyGroups false to set privacy group value to + * null, true to let it as is. + */ + public void resetImport(Layout parentLayout, boolean keepPrivacyGroups) { + this.id = null; + this.parentLayout = parentLayout; + + if (this.constraints != null) { + for (LayoutConstraint layoutConstraint : constraints) { + if (layoutConstraint != null) { + layoutConstraint.resetImport(this, keepPrivacyGroups); + } + } + } + } + + /** + * {@inheritDoc} + */ + @Override + public void appendToString(final ToStringBuilder builder) { + builder.append("row", row); + builder.append("column", column); + builder.append("title", title); + } - public LayoutGroup() { - } - - /** - * Adds a constraint to the current layout group if it is not null. - * - * @param constraint - * The constraint to add. - */ - public void addConstraint(LayoutConstraint constraint) { - - if (constraint == null) { - return; - } - - constraint.setParentLayoutGroup(this); - constraints.add(constraint); - } - - /** - * Reset the identifiers of the object. - * - * @param parentLayout - * the parent Layout - * @param keepPrivacyGroups - * false to set privacy group value to null, true to let it as is. - */ - public void resetImport(Layout parentLayout, boolean keepPrivacyGroups) { - this.id = null; - this.parentLayout = parentLayout; - - if (this.constraints != null) { - for (LayoutConstraint layoutConstraint : constraints) { - if (layoutConstraint != null) { - layoutConstraint.resetImport(this, keepPrivacyGroups); - } - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public void appendToString(final ToStringBuilder builder) { - builder.append("row", row); - builder.append("column", column); - builder.append("title", title); - } - - // -------------------------------------------------------------------------------- - // - // GETTERS & SETTERS. - // // -------------------------------------------------------------------------------- - - @Override - public Integer getId() { - return id; - } - - @Override - public void setId(Integer id) { - this.id = id; - } - - public void setParentLayout(Layout parentLayout) { - this.parentLayout = parentLayout; - } - - public Layout getParentLayout() { - return parentLayout; - } - - public void setRow(Integer row) { - this.row = row; - } - - public Integer getRow() { - return row; - } - - public void setColumn(Integer column) { - this.column = column; - } - - public Integer getColumn() { - return column; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getTitle() { - return title; - } - - public void setConstraints(List constraints) { - this.constraints = constraints; - } - - public List getConstraints() { - return constraints; - } + // + // GETTERS & SETTERS. + // + // -------------------------------------------------------------------------------- + @Override + public Integer getId() { + return id; + } + + @Override + public void setId(Integer id) { + this.id = id; + } + + public void setParentLayout(Layout parentLayout) { + this.parentLayout = parentLayout; + } + + public Layout getParentLayout() { + return parentLayout; + } + + public void setRow(Integer row) { + this.row = row; + } + + public Integer getRow() { + return row; + } + + public void setColumn(Integer column) { + this.column = column; + } + + public Integer getColumn() { + return column; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getTitle() { + return title; + } + + public void setConstraints(List constraints) { + this.constraints = constraints; + } + + public List getConstraints() { + return constraints; + } } diff --git a/src/main/java/org/sigmah/server/handler/DeleteGroupsHandler.java b/src/main/java/org/sigmah/server/handler/DeleteGroupsHandler.java new file mode 100644 index 000000000..ccc004d39 --- /dev/null +++ b/src/main/java/org/sigmah/server/handler/DeleteGroupsHandler.java @@ -0,0 +1,78 @@ +package org.sigmah.server.handler; + +/* + * #%L + * Sigmah + * %% + * Copyright (C) 2010 - 2016 URD + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ +import java.util.List; + +import org.sigmah.server.dispatch.impl.UserDispatch.UserExecutionContext; +import org.sigmah.server.domain.layout.LayoutGroup; +import org.sigmah.server.handler.base.AbstractCommandHandler; +import org.sigmah.shared.command.DeleteGroups; +import org.sigmah.shared.command.result.VoidResult; +import org.sigmah.shared.dispatch.CommandException; +import org.sigmah.shared.dto.layout.LayoutGroupDTO; + +import com.google.inject.Inject; +import com.google.inject.persist.Transactional; + +/** + * Handler for {@link DeleteGroups} command + * + * @author Nikita Jibhkate (niksj1996@gmail.com)) + */ +public class DeleteGroupsHandler extends AbstractCommandHandler { + + @Inject + public DeleteGroupsHandler() { + + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + @Override + public VoidResult execute(final DeleteGroups cmd, final UserExecutionContext context) throws CommandException { + + if (cmd.getLayoutGroups() != null) { + + performDelete(cmd.getLayoutGroups()); + } + + return null; + } + + @Transactional + protected void performDelete(List groups) { + if (groups != null) { + for (LayoutGroupDTO layoutgroup : groups) { + LayoutGroup lg = em().find(LayoutGroup.class, layoutgroup.getId()); + if (lg != null) { + em().remove(lg); + } + } + } + + em().flush(); + } + +} diff --git a/src/main/java/org/sigmah/server/inject/CommandHandlerModule.java b/src/main/java/org/sigmah/server/inject/CommandHandlerModule.java index af8f0343a..da9071def 100644 --- a/src/main/java/org/sigmah/server/inject/CommandHandlerModule.java +++ b/src/main/java/org/sigmah/server/inject/CommandHandlerModule.java @@ -61,6 +61,7 @@ protected void configureHandlers() { bindHandler(DisableFlexibleElements.class, DisableFlexibleElementsHandler.class); bindHandler(DeleteCategories.class, DeleteCategoriesHandler.class); bindHandler(DeleteFlexibleElements.class, DeleteFlexibleElementsHandler.class); + bindHandler(DeleteGroups.class, DeleteGroupsHandler.class); bindHandler(Delete.class, DeleteHandler.class); bindHandler(DeleteImportationSchemeModels.class, DeleteImportationSchemeModelsHandler.class); bindHandler(DeleteImportationSchemes.class, DeleteImportationSchemesHandler.class); diff --git a/src/main/java/org/sigmah/shared/command/DeleteGroups.java b/src/main/java/org/sigmah/shared/command/DeleteGroups.java new file mode 100644 index 000000000..bacfd5b4f --- /dev/null +++ b/src/main/java/org/sigmah/shared/command/DeleteGroups.java @@ -0,0 +1,65 @@ +package org.sigmah.shared.command; + +/* + * #%L + * Sigmah + * %% + * Copyright (C) 2010 - 2016 URD + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ + +import java.util.ArrayList; +import java.util.List; + +import org.sigmah.shared.command.base.AbstractCommand; +import org.sigmah.shared.command.result.VoidResult; +import org.sigmah.shared.dto.layout.LayoutGroupDTO; + +/** + * @author Nikita Jibhkate (niksj1996@gmail.com) + */ +public class DeleteGroups extends AbstractCommand { + + private List flexElts; + + protected DeleteGroups() { + // Serialization. + } + + public DeleteGroups(List fe) { + this.setLayoutGroups(fe); + } + + public void setLayoutGroups(List fe) { + this.flexElts = fe; + } + + public List getLayoutGroups() { + return flexElts; + } + + public void addGroups(LayoutGroupDTO flexElt) { + if (flexElts == null) { + flexElts = new ArrayList(); + } + this.flexElts.add(flexElt); + } + + public void removeGroups(List flexElt) { + this.flexElts.remove(flexElt); + } +} diff --git a/src/main/java/org/sigmah/shared/dto/IsModel.java b/src/main/java/org/sigmah/shared/dto/IsModel.java index 5e229f1bb..be26fd56e 100644 --- a/src/main/java/org/sigmah/shared/dto/IsModel.java +++ b/src/main/java/org/sigmah/shared/dto/IsModel.java @@ -1,33 +1,34 @@ -package org.sigmah.shared.dto; - -/* - * #%L - * Sigmah - * %% - * Copyright (C) 2010 - 2016 URD - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * . - * #L% - */ - +package org.sigmah.shared.dto; + +/* + * #%L + * Sigmah + * %% + * Copyright (C) 2010 - 2016 URD + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ + import java.util.List; import org.sigmah.shared.dto.base.AbstractModelDataEntityDTO; import org.sigmah.shared.dto.base.EntityDTO; import org.sigmah.shared.dto.element.FlexibleElementDTO; +import org.sigmah.shared.dto.layout.LayoutGroupDTO; import org.sigmah.shared.dto.referential.ProjectModelStatus; import com.extjs.gxt.ui.client.data.ModelData; @@ -86,6 +87,13 @@ public static enum ModelType { * @return The current model corresponding all flexible elements. */ List getAllElements(); + + /** + * Returns the current model corresponding all layoutGroups. + * + * @return The current model corresponding all layoutGroups. + */ + List getAllGroups(); /** * Returns the model elements that handle a layout.
diff --git a/src/main/java/org/sigmah/shared/dto/OrgUnitModelDTO.java b/src/main/java/org/sigmah/shared/dto/OrgUnitModelDTO.java index f7ecc1003..e1f366275 100644 --- a/src/main/java/org/sigmah/shared/dto/OrgUnitModelDTO.java +++ b/src/main/java/org/sigmah/shared/dto/OrgUnitModelDTO.java @@ -1,27 +1,27 @@ -package org.sigmah.shared.dto; - -/* - * #%L - * Sigmah - * %% - * Copyright (C) 2010 - 2016 URD - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * . - * #L% - */ - +package org.sigmah.shared.dto; + +/* + * #%L + * Sigmah + * %% + * Copyright (C) 2010 - 2016 URD + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ + import java.util.ArrayList; import java.util.Date; @@ -327,7 +327,41 @@ public List getAllElements() { return allElements; } - + + /** + * {@inheritDoc} + */ + @Override + public List getAllGroups() { + List allElements = new ArrayList(); + List bannerElements = new ArrayList(); + + // banner + if (this.getBanner().getLayout() != null) { + for (LayoutGroupDTO lg : getBanner().getLayout().getGroups()) { + + bannerElements.add(lg); + + } + } + + // Details + OrgUnitDetailsDTO d = getDetails(); + d.setName(); + setDetails(d); + if (getDetails().getLayout() != null) { + for (LayoutGroupDTO lg : getDetails().getLayout().getGroups()) { + LayoutConstraintDTO lc = lg.getConstraint(); + lg.setConstraint(lc); + + lg.setContainerModel(getDetails()); + allElements.add(lg); + } + } + + return allElements; + } + /** * Gets all the flexible elements instances of the given class in this model (details page). The banner is ignored * cause the elements in it are read-only. diff --git a/src/main/java/org/sigmah/shared/dto/ProjectModelDTO.java b/src/main/java/org/sigmah/shared/dto/ProjectModelDTO.java index d7c054d80..ca33cc059 100644 --- a/src/main/java/org/sigmah/shared/dto/ProjectModelDTO.java +++ b/src/main/java/org/sigmah/shared/dto/ProjectModelDTO.java @@ -70,6 +70,7 @@ public class ProjectModelDTO extends AbstractModelDataEntityDTO impleme public static final String PROJECT_BANNER = "projectBanner"; public static final String PROJECT_DETAILS = "projectDetails"; public static final String LOG_FRAME_MODEL = "logFrameModel"; + public static final String LAYOUT_GROUP = "groups"; public static final String MAINTENANCE_DATE = "dateMaintenance"; public static final String UNDER_MAINTENANCE = "underMaintenance"; public static final String DEFAULT_TEAM_MEMBER_PROFILES = "defaultTeamMemberProfiles"; @@ -198,6 +199,7 @@ public PhaseModelDTO getPhaseModel() { private transient HashMap, List> localizedElements; private transient List allElements; + private transient List allGroupElements; public ProjectModelDTO() { // Serialization. @@ -561,6 +563,76 @@ public List getAllElements() { return allElements; } + /** + * {@inheritDoc} + */ + @Override + public List getAllGroups() { + + if (this.allGroupElements != null) { + return this.allGroupElements; + } + + final List allGroupElements = new ArrayList(); + final List bannerElements = new ArrayList(); +// -- + // Banner. + // -- + + if (this.getProjectBanner().getLayout() != null) { + for (final LayoutGroupDTO lg : getProjectBanner().getLayout().getGroups()) { + + bannerElements.add(lg); + } + } + + + // -- + // Phases. + // -- + + for (final PhaseModelDTO phaseModel : getPhaseModels()) { + if (phaseModel != null) { + final LayoutDTO layout = phaseModel.getLayout(); + if (layout != null) { + for (final LayoutGroupDTO lg : layout.getGroups()) { + final LayoutConstraintDTO lc = lg.getConstraint(); + + lg.setConstraint(lc); + lg.setContainerModel(phaseModel); + + allGroupElements.add(lg); + } + } + } + } + + + // -- + // Project Details. + // -- + + final ProjectDetailsDTO p = getProjectDetails(); + p.setName(); + setProjectDetails(p); + if (getProjectDetails().getLayout() != null) { + for (final LayoutGroupDTO lg : getProjectDetails().getLayout().getGroups()) { + final LayoutConstraintDTO lc = lg.getConstraint(); + + lg.setConstraint(lc); + + lg.setContainerModel(getProjectDetails()); + + allGroupElements.add(lg); + } + } + + + this.allGroupElements = allGroupElements; + + return allGroupElements; + } + /** * Gets all the flexible elements instances of the given class in this model (phases and details page). The banner is * ignored cause the elements in it are read-only. diff --git a/src/main/java/org/sigmah/shared/dto/layout/LayoutGroupDTO.java b/src/main/java/org/sigmah/shared/dto/layout/LayoutGroupDTO.java index df512b572..3bb57333a 100644 --- a/src/main/java/org/sigmah/shared/dto/layout/LayoutGroupDTO.java +++ b/src/main/java/org/sigmah/shared/dto/layout/LayoutGroupDTO.java @@ -3,7 +3,6 @@ /* * #%L * Sigmah - * %% * Copyright (C) 2010 - 2016 URD * %% * This program is free software: you can redistribute it and/or modify @@ -21,7 +20,7 @@ * . * #L% */ - +import com.extjs.gxt.ui.client.data.BaseModelData; import java.util.List; import org.sigmah.client.util.ToStringBuilder; @@ -33,102 +32,121 @@ /** * LayoutGroupDTO. - * + * * @author Denis Colliot (dcolliot@ideia.fr) */ public class LayoutGroupDTO extends AbstractModelDataEntityDTO { - /** - * Serial version UID. - */ - private static final long serialVersionUID = 8520711106031085130L; - - /** - * DTO corresponding entity name. - */ - public static final String ENTITY_NAME = "layout.LayoutGroup"; - - // DTO attributes keys. - public static final String TITLE = "title"; - public static final String ROW = "row"; - public static final String COLUMN = "column"; - public static final String PARENT_LAYOUT = "parentLayout"; - public static final String CONSTRAINTS = "constraints"; - - /** - * {@inheritDoc} - */ - @Override - public String getEntityName() { - return ENTITY_NAME; - } - - /** - * {@inheritDoc} - */ - @Override - protected void appendToString(final ToStringBuilder builder) { - builder.append(TITLE, getTitle()); - builder.append(ROW, getRow()); - builder.append(COLUMN, getColumn()); - } - - // Layout group title - public String getTitle() { - return get(TITLE); - } - - public void setTitle(String title) { - set(TITLE, title); - } - - // Row index - public Integer getRow() { - return (Integer) get(ROW); - } - - public void setRow(Integer row) { - set(ROW, row); - } - - // Column index - public Integer getColumn() { - return (Integer) get(COLUMN); - } - - public void setColumn(Integer column) { - set(COLUMN, column); - } - - // Reference to layoutDTO - public LayoutDTO getParentLayout() { - return get(PARENT_LAYOUT); - } - - public void setParentLayout(LayoutDTO parentLayout) { - set(PARENT_LAYOUT, parentLayout); - } - - // Reference to layout group constraints list - public List getConstraints() { - return get(CONSTRAINTS); - } - - public void setConstraints(List constraints) { - set(CONSTRAINTS, constraints); - } - - public Widget getWidget() { - final FieldSet fieldSet = new FieldSet(); - fieldSet.setHeadingHtml(getTitle()); - fieldSet.setCollapsible(true); - - final FormLayout formLayout = new FormLayout(); - formLayout.setLabelWidth(250); - - fieldSet.setLayout(formLayout); - - return fieldSet; - } + /** + * Serial version UID. + */ + private static final long serialVersionUID = 8520711106031085130L; + + /** + * DTO corresponding entity name. + */ + public static final String ENTITY_NAME = "layout.LayoutGroup"; + + // DTO attributes keys. + public static final String TITLE = "title"; + public static final String ROW = "row"; + public static final String COLUMN = "column"; + public static final String PARENT_LAYOUT = "parentLayout"; + public static final String CONSTRAINTS = "constraints"; + public static final String CONTAINER = "container"; + public static final String CONSTRAINT = "constraint"; + public static final String IS_DISABLED = "isdisabled"; + + /** + * {@inheritDoc} + */ + @Override + public String getEntityName() { + return ENTITY_NAME; + } + + /** + * {@inheritDoc} + */ + @Override + protected void appendToString(final ToStringBuilder builder) { + builder.append(TITLE, getTitle()); + builder.append(ROW, getRow()); + builder.append(COLUMN, getColumn()); + } + + // Layout group title + public String getTitle() { + return get(TITLE); + } + + public void setTitle(String title) { + set(TITLE, title); + } + + // Row index + public Integer getRow() { + return (Integer) get(ROW); + } + + public void setRow(Integer row) { + set(ROW, row); + } + + // Column index + public Integer getColumn() { + return (Integer) get(COLUMN); + } + + public void setColumn(Integer column) { + set(COLUMN, column); + } + + // Reference to layoutDTO + public LayoutDTO getParentLayout() { + return get(PARENT_LAYOUT); + } + + public void setParentLayout(LayoutDTO parentLayout) { + set(PARENT_LAYOUT, parentLayout); + } + + // Reference to layout group constraints list + public List getConstraints() { + return get(CONSTRAINTS); + } + + public void setConstraints(List constraints) { + set(CONSTRAINTS, constraints); + } + + public BaseModelData getContainerModel() { + return get(CONTAINER); + } + + public void setContainerModel(BaseModelData model) { + set(CONTAINER, model); + } + + public LayoutConstraintDTO getConstraint() { + return get(CONSTRAINT); + } + + public void setConstraint(LayoutConstraintDTO constraint) { + set(CONSTRAINT, constraint); + } + + public Widget getWidget() { + final FieldSet fieldSet = new FieldSet(); + fieldSet.setHeadingHtml(getTitle()); + fieldSet.setCollapsible(true); + + final FormLayout formLayout = new FormLayout(); + formLayout.setLabelWidth(250); + + fieldSet.setLayout(formLayout); + + return fieldSet; + } } diff --git a/src/main/resources/org/sigmah/client/i18n/UIConstants.properties b/src/main/resources/org/sigmah/client/i18n/UIConstants.properties index dd875c832..9c7abef68 100644 --- a/src/main/resources/org/sigmah/client/i18n/UIConstants.properties +++ b/src/main/resources/org/sigmah/client/i18n/UIConstants.properties @@ -191,6 +191,7 @@ adminFlexibleComputationFormulaHint=Formula only accepts field codes, spaces and # Message displayed above the code grid. adminFlexibleComputationCodeGridHeader=Editable list of available fields in this model: adminFlexibleConfirmDelete=Are you sure you want to delete the following fields ? +adminGroupsConfirmDelete=Are you sure you want to delete the following groups ? adminFlexibleComputationRuleBadFormula=Formula is incorrect. adminErrorDeleteDefaultFlexible=You are not authorised to delete the following compulsory fields: adminLogFrameActivities=Activities (A) @@ -279,6 +280,8 @@ adminPrivacyGroupAdd=Add group adminPrivacyGroupChoice=Select a privacy group... adminPrivacyGroupCreationBox=Saving privacy groups... adminPrivacyGroupDelete=Delete group +adminProjectModelGroups=Groups +adminGroupsPosition=Position # Privacy groups administration adminPrivacyGroups=Privacy groups adminPrivacyGroupsCode=Code @@ -1266,6 +1269,7 @@ adminPhaseModelDeleteDetail=The phase model has been deleted. deleteRootPhaseModelConfirm=Warning: This is the last phase of this project model. All fields using this phase will also be deleted. The projects using this project model may not work any more. Are you sure you want to delete it? deleteRootPhaseModelError=You can not delete this phase because it is the initial phase. adminFlexibleDeleteFlexibleElementsConfirm=The selected fields have been successfully deleted. +adminDeleteLayoutGroupsConfirm=The selected groups have been successfully deleted. changeOrgUnit=Change organisational unit changeOrgUnitDetails=Warning: The project will remain attached to the current country for the management of indicator sites, not the country linked to the new organisational unit. Are you sure you want to continue? projectChangeStatus=Changing model's status diff --git a/src/main/resources/org/sigmah/client/i18n/UIMessages.properties b/src/main/resources/org/sigmah/client/i18n/UIMessages.properties index 363562912..8f9f99f98 100644 --- a/src/main/resources/org/sigmah/client/i18n/UIMessages.properties +++ b/src/main/resources/org/sigmah/client/i18n/UIMessages.properties @@ -41,6 +41,7 @@ activityAt={0} at {1} activityTitle={0} - {1} #Default flexible element adminFlexibleDeleteNone=You have not selected a field. Please select one row or more. +adminGroupsDeleteNone=You have not selected a group. Please select one row or more. # Ask the new code of a flexible element. adminFlexibleEditCode=New code for the field ''{0}'': adminFlexibleComputationRuleBadReference=Code ''{0}'' is not a valid code.