diff --git a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/AppPresenter.groovy b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/AppPresenter.groovy index e8c606915..be8f6adb8 100644 --- a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/AppPresenter.groovy +++ b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/AppPresenter.groovy @@ -1,7 +1,6 @@ package life.qbic.portal.offermanager.components import life.qbic.business.UseCaseFailure -import life.qbic.portal.offermanager.components.AppViewModel /** * Handles the presentation of the qoffer-2.0 use cases and its internal data model to the ViewModel. diff --git a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/ConfirmationDialog.groovy b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/ConfirmationDialog.groovy index b779e4aaf..d43acd02e 100644 --- a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/ConfirmationDialog.groovy +++ b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/ConfirmationDialog.groovy @@ -1,12 +1,6 @@ package life.qbic.portal.offermanager.components -import com.vaadin.ui.Alignment -import com.vaadin.ui.Button -import com.vaadin.ui.HorizontalLayout -import com.vaadin.ui.Label -import com.vaadin.ui.VerticalLayout -import com.vaadin.ui.Window -import com.vaadin.ui.themes.ValoTheme +import com.vaadin.ui.* /** *

Dialog to ask for user confirmation

@@ -72,4 +66,4 @@ class ConfirmationDialog extends Window{ }) } -} \ No newline at end of file +} diff --git a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/CreateOfferView.groovy b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/CreateOfferView.groovy index 778082d8a..0d456018b 100644 --- a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/CreateOfferView.groovy +++ b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/CreateOfferView.groovy @@ -198,9 +198,13 @@ class CreateOfferView extends FormLayout{ */ private static List getProductItems(List items){ List productItems = [] - items.each { - productItems.add(new ProductItem(it.quantity,it.product)) + for (int position = 0; position < items.size(); position++) { + ProductItemViewModel currentItem = items.get(position) + ProductItem productItem = new ProductItem(currentItem.quantity, currentItem.product) + productItem.setOrderPosition(position) + productItems.add(productItem) } + return productItems } diff --git a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/OfferOverviewView.groovy b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/OfferOverviewView.groovy index db3a366b5..9d25b24ce 100644 --- a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/OfferOverviewView.groovy +++ b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/OfferOverviewView.groovy @@ -3,6 +3,7 @@ package life.qbic.portal.offermanager.components.offer.create import com.vaadin.data.provider.ListDataProvider import com.vaadin.icons.VaadinIcons import com.vaadin.ui.* +import com.vaadin.ui.components.grid.GridRowDragger import com.vaadin.ui.components.grid.HeaderRow import com.vaadin.ui.renderers.NumberRenderer import com.vaadin.ui.themes.ValoTheme @@ -42,6 +43,7 @@ class OfferOverviewView extends VerticalLayout { ListDataProvider dataProvider = new ListDataProvider(createOfferViewModel.getProductItems()) itemGrid.setDataProvider(dataProvider) + enableDraggable(itemGrid) setupFilters(dataProvider, itemGrid) } @@ -56,6 +58,13 @@ class OfferOverviewView extends VerticalLayout { customerFilterRow) } + static void enableDraggable(Grid grid) { + new GridRowDragger<>(grid) + grid.setStyleGenerator(row -> { + return "draggable-row-grab" + }) + } + /** * Initializes the start layout for this view */ @@ -210,7 +219,6 @@ class OfferOverviewView extends VerticalLayout { Small helper object, that will display information about individual price positions for offer overviews. */ - private class PriceField { String name diff --git a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/ProjectInformationView.groovy b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/ProjectInformationView.groovy index 0319f79e0..28555de77 100644 --- a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/ProjectInformationView.groovy +++ b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/ProjectInformationView.groovy @@ -1,6 +1,5 @@ package life.qbic.portal.offermanager.components.offer.create - import com.vaadin.data.ValidationResult import com.vaadin.data.Validator import com.vaadin.data.ValueContext @@ -8,7 +7,6 @@ import com.vaadin.icons.VaadinIcons import com.vaadin.server.UserError import com.vaadin.ui.* import com.vaadin.ui.themes.ValoTheme -import groovy.beans.Bindable import life.qbic.portal.offermanager.components.Resettable /** diff --git a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/ProjectManagerSelectionView.groovy b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/ProjectManagerSelectionView.groovy index 9c5e400ec..d615cba30 100644 --- a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/ProjectManagerSelectionView.groovy +++ b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/ProjectManagerSelectionView.groovy @@ -9,7 +9,6 @@ import com.vaadin.ui.themes.ValoTheme import life.qbic.datamodel.dtos.business.ProjectManager import life.qbic.portal.offermanager.components.GridUtils import life.qbic.portal.offermanager.components.Resettable -import life.qbic.portal.offermanager.components.offer.create.CreateOfferViewModel /** * This class generates a Layout in which the user diff --git a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/SelectItemsView.groovy b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/SelectItemsView.groovy index cdac8ba3c..4b8c29e2b 100644 --- a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/SelectItemsView.groovy +++ b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/create/SelectItemsView.groovy @@ -10,6 +10,7 @@ import com.vaadin.server.UserError import com.vaadin.shared.data.sort.SortDirection import com.vaadin.shared.ui.grid.HeightMode import com.vaadin.ui.* +import com.vaadin.ui.components.grid.GridRowDragger import com.vaadin.ui.components.grid.HeaderRow import com.vaadin.ui.renderers.NumberRenderer import com.vaadin.ui.themes.ValoTheme @@ -78,6 +79,13 @@ class SelectItemsView extends VerticalLayout implements Resettable { TabSheet packageAccordion + static void enableDraggable(Grid grid) { + new GridRowDragger<>(grid) + grid.setStyleGenerator(row -> { + return "draggable-row-grab" + }) + } + /** * Contains regex for filtering the different product types * @@ -312,6 +320,7 @@ class SelectItemsView extends VerticalLayout implements Resettable { generateProductGrid(externalServiceGrid) // This grid summarises product items selected for this specific offer, so we set quantity = true generateItemGrid(overviewGrid) + enableDraggable(overviewGrid) packageAccordion = new TabSheet() packageAccordion.addTab(seqLayout, "Sequencing") diff --git a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/overview/projectcreation/CreateProjectView.groovy b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/overview/projectcreation/CreateProjectView.groovy index 58e1654b9..80caf3261 100644 --- a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/overview/projectcreation/CreateProjectView.groovy +++ b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/overview/projectcreation/CreateProjectView.groovy @@ -2,25 +2,13 @@ package life.qbic.portal.offermanager.components.offer.overview.projectcreation import com.vaadin.icons.VaadinIcons import com.vaadin.shared.ui.ContentMode -import com.vaadin.ui.Alignment -import com.vaadin.ui.Button -import com.vaadin.ui.ComboBox -import com.vaadin.ui.GridLayout -import com.vaadin.ui.HorizontalLayout -import com.vaadin.ui.Label -import com.vaadin.ui.Panel -import com.vaadin.ui.RadioButtonGroup -import com.vaadin.ui.TextArea -import com.vaadin.ui.TextField -import com.vaadin.ui.VerticalLayout +import com.vaadin.ui.* import com.vaadin.ui.themes.ValoTheme import life.qbic.datamodel.dtos.business.Offer import life.qbic.datamodel.dtos.projectmanagement.ProjectCode import life.qbic.datamodel.dtos.projectmanagement.ProjectIdentifier import life.qbic.datamodel.dtos.projectmanagement.ProjectSpace - - /** *

Enables a user to create a project based on an existing offer

* diff --git a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/overview/projectcreation/CreateProjectViewModel.groovy b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/overview/projectcreation/CreateProjectViewModel.groovy index cb3b60efc..179a09d03 100644 --- a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/overview/projectcreation/CreateProjectViewModel.groovy +++ b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/overview/projectcreation/CreateProjectViewModel.groovy @@ -9,8 +9,6 @@ import life.qbic.datamodel.dtos.projectmanagement.ProjectCode import life.qbic.datamodel.dtos.projectmanagement.ProjectIdentifier import life.qbic.datamodel.dtos.projectmanagement.ProjectSpace import life.qbic.portal.offermanager.dataresources.ResourcesService -import life.qbic.portal.offermanager.dataresources.projects.ProjectResourceService -import life.qbic.portal.offermanager.dataresources.projects.ProjectSpaceResourceService /** *

Holds the create project state information and logic

diff --git a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/update/UpdateOfferView.groovy b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/update/UpdateOfferView.groovy index 4d91214e8..332b72f11 100644 --- a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/update/UpdateOfferView.groovy +++ b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/update/UpdateOfferView.groovy @@ -199,9 +199,13 @@ class UpdateOfferView extends FormLayout { */ private static List getProductItems(List items) { List productItems = [] - items.each { - productItems.add(new ProductItem(it.quantity, it.product)) + for (int position = 0; position < items.size(); position++) { + ProductItemViewModel currentItem = items.get(position) + ProductItem productItem = new ProductItem(currentItem.quantity, currentItem.product) + productItem.setOrderPosition(position) + productItems.add(productItem) } + return productItems } diff --git a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/update/UpdateOfferViewModel.groovy b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/update/UpdateOfferViewModel.groovy index bc33dca09..1b1f4bcc2 100644 --- a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/update/UpdateOfferViewModel.groovy +++ b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/offer/update/UpdateOfferViewModel.groovy @@ -2,6 +2,7 @@ package life.qbic.portal.offermanager.components.offer.update import life.qbic.datamodel.dtos.business.Customer import life.qbic.datamodel.dtos.business.Offer +import life.qbic.datamodel.dtos.business.ProductItem import life.qbic.datamodel.dtos.business.ProjectManager import life.qbic.datamodel.dtos.business.services.Product import life.qbic.datamodel.dtos.general.Person @@ -10,6 +11,8 @@ import life.qbic.portal.offermanager.components.offer.create.CreateOfferViewMode import life.qbic.portal.offermanager.components.offer.create.ProductItemViewModel import life.qbic.portal.offermanager.dataresources.ResourcesService +import java.util.stream.Collectors + /** * Model with data for updating an existing offer. * @@ -23,7 +26,7 @@ import life.qbic.portal.offermanager.dataresources.ResourcesService * * @since 1.0.0 */ -class UpdateOfferViewModel extends CreateOfferViewModel{ +class UpdateOfferViewModel extends CreateOfferViewModel { final private EventEmitter offerUpdate @@ -50,8 +53,15 @@ class UpdateOfferViewModel extends CreateOfferViewModel{ super.projectManager = offer.projectManager super.experimentalDesign = offer.experimentalDesign.orElse("") super.productItems.clear() - super.productItems.addAll(offer.items.collect { - new ProductItemViewModel(it.quantity, it.product)}) + + super.productItems.addAll( + offer.items.stream().sorted(new Comparator() { + @Override + int compare(ProductItem o1, ProductItem o2) { + return o1.offerPosition() - o2.offerPosition() + } + }).map(productItem -> new ProductItemViewModel(productItem.quantity, productItem.product)).collect(Collectors.toList()) + ) super.savedOffer = Optional.of(offer) validateProjectInformation() } diff --git a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/person/update/UpdatePersonView.groovy b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/person/update/UpdatePersonView.groovy index c4d0ce792..e69d1d026 100644 --- a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/person/update/UpdatePersonView.groovy +++ b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/components/person/update/UpdatePersonView.groovy @@ -1,8 +1,6 @@ package life.qbic.portal.offermanager.components.person.update - import com.vaadin.data.provider.ListDataProvider -import com.vaadin.event.selection.SelectionListener import com.vaadin.icons.VaadinIcons import com.vaadin.shared.ui.grid.HeightMode import com.vaadin.ui.Button diff --git a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/security/liferay/LiferayRoleService.groovy b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/security/liferay/LiferayRoleService.groovy index 1f999d595..e4c3a70b5 100644 --- a/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/security/liferay/LiferayRoleService.groovy +++ b/offer-manager-app/src/main/groovy/life/qbic/portal/offermanager/security/liferay/LiferayRoleService.groovy @@ -1,10 +1,8 @@ package life.qbic.portal.offermanager.security.liferay import com.liferay.portal.kernel.exception.PortalException -import com.liferay.portal.model.User import com.liferay.portal.model.UserGroupRole import com.liferay.portal.service.UserGroupRoleLocalServiceUtil -import com.liferay.portal.service.UserLocalServiceUtil import groovy.util.logging.Log4j2 import life.qbic.portal.offermanager.security.Role import life.qbic.portal.offermanager.security.RoleService diff --git a/offer-manager-app/src/main/webapp/VAADIN/themes/mytheme/mytheme.scss b/offer-manager-app/src/main/webapp/VAADIN/themes/mytheme/mytheme.scss index 2431a6747..d5c0ab8b2 100644 --- a/offer-manager-app/src/main/webapp/VAADIN/themes/mytheme/mytheme.scss +++ b/offer-manager-app/src/main/webapp/VAADIN/themes/mytheme/mytheme.scss @@ -49,4 +49,12 @@ .scrollable-layout { overflow: auto; } + + .draggable-row-grab:hover { + cursor: grab; + } + + .draggable-row-grab:active { + cursor: grabbing; + } } diff --git a/offer-manager-app/src/main/webapp/WEB-INF/web.xml b/offer-manager-app/src/main/webapp/WEB-INF/web.xml index d96d21667..db255a997 100644 --- a/offer-manager-app/src/main/webapp/WEB-INF/web.xml +++ b/offer-manager-app/src/main/webapp/WEB-INF/web.xml @@ -1,6 +1,5 @@ - +