コード例 #1
0
  @Override
  protected void onGo(ComponentContainer container, ScreenData<?> data) {
    CrmToolbar.navigateItem(CrmTypeConstants.LEAD);
    if (AppContext.canRead(RolePermissionCollections.CRM_LEAD)) {
      if (data.getParams() instanceof SimpleLead) {
        SimpleLead lead = (SimpleLead) data.getParams();
        super.onGo(container, data);
        view.previewItem(lead);

        AppContext.addFragment(
            CrmLinkGenerator.generateLeadPreviewLink(lead.getId()),
            AppContext.getMessage(
                GenericI18Enum.BROWSER_PREVIEW_ITEM_TITLE, "Lead", lead.getLeadName()));
      }
    } else {
      NotificationUtil.showMessagePermissionAlert();
    }
  }
コード例 #2
0
 @Override
 protected String initFormTitle() {
   // check if there is converted lead associates with this contact
   LeadService leadService = ApplicationContextUtil.getSpringBean(LeadService.class);
   SimpleLead lead =
       leadService.findConvertedLeadOfContact(beanItem.getId(), AppContext.getAccountId());
   if (lead != null) {
     return "<h2>"
         + beanItem.getContactName()
         + LocalizationHelper.getMessage(
             LeadI18nEnum.CONVERT_FROM_LEAD_TITLE,
             CrmResources.getResourceLink(CrmTypeConstants.LEAD),
             CrmLinkGenerator.generateCrmItemLink(CrmTypeConstants.LEAD, lead.getId()),
             lead.getLeadName())
         + "</h2>";
   } else {
     return beanItem.getContactName();
   }
 }
コード例 #3
0
    @Override
    public Component generateBlock(final SimpleOpportunity opportunity, int blockIndex) {
      CssLayout beanBlock = new CssLayout();
      beanBlock.addStyleName("bean-block");
      beanBlock.setWidth("350px");

      VerticalLayout blockContent = new VerticalLayout();
      MHorizontalLayout blockTop = new MHorizontalLayout().withWidth("100%");
      CssLayout iconWrap = new CssLayout();
      iconWrap.setStyleName("icon-wrap");
      FontIconLabel opportunityIcon =
          new FontIconLabel(CrmAssetsManager.getAsset(CrmTypeConstants.OPPORTUNITY));
      iconWrap.addComponent(opportunityIcon);
      blockTop.addComponent(iconWrap);

      VerticalLayout opportunityInfo = new VerticalLayout();
      opportunityInfo.setSpacing(true);

      MButton btnDelete = new MButton(FontAwesome.TRASH_O);
      btnDelete.addClickListener(
          new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent clickEvent) {
              ConfirmDialogExt.show(
                  UI.getCurrent(),
                  AppContext.getMessage(
                      GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.getSiteName()),
                  AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                  AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                  AppContext.getMessage(GenericI18Enum.BUTTON_NO),
                  new ConfirmDialog.Listener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClose(ConfirmDialog dialog) {
                      if (dialog.isConfirmed()) {
                        ContactService contactService =
                            ApplicationContextUtil.getSpringBean(ContactService.class);
                        ContactOpportunity associateOpportunity = new ContactOpportunity();
                        associateOpportunity.setContactid(contact.getId());
                        associateOpportunity.setOpportunityid(opportunity.getId());
                        contactService.removeContactOpportunityRelationship(
                            associateOpportunity, AppContext.getAccountId());
                        ContactOpportunityListComp.this.refresh();
                      }
                    }
                  });
            }
          });

      btnDelete.addStyleName(UIConstants.BUTTON_ICON_ONLY);

      blockContent.addComponent(btnDelete);
      blockContent.setComponentAlignment(btnDelete, Alignment.TOP_RIGHT);

      Label opportunityName =
          new Label(
              String.format(
                  "Name: <a href='%s%s'>%s</a>",
                  SiteConfiguration.getSiteUrl(AppContext.getUser().getSubdomain()),
                  CrmLinkGenerator.generateCrmItemLink(
                      CrmTypeConstants.OPPORTUNITY, opportunity.getId()),
                  opportunity.getOpportunityname()),
              ContentMode.HTML);

      opportunityInfo.addComponent(opportunityName);

      Label opportunityAmount =
          new Label("Amount: " + (opportunity.getAmount() != null ? opportunity.getAmount() : ""));
      if (opportunity.getCurrency() != null && opportunity.getAmount() != null) {
        opportunityAmount.setValue(
            opportunityAmount.getValue() + opportunity.getCurrency().getSymbol());
      }
      opportunityInfo.addComponent(opportunityAmount);

      Label opportunitySaleStage =
          new Label(
              "Sale Stage: "
                  + (opportunity.getSalesstage() != null ? opportunity.getSalesstage() : ""));
      opportunityInfo.addComponent(opportunitySaleStage);

      ELabel opportunityExpectedCloseDate =
          new ELabel(
                  "Expected Closed Date: "
                      + AppContext.formatPrettyTime(opportunity.getExpectedcloseddate()))
              .withDescription(AppContext.formatDate(opportunity.getExpectedcloseddate()));
      opportunityInfo.addComponent(opportunityExpectedCloseDate);

      blockTop.with(opportunityInfo).expand(opportunityInfo);
      blockContent.addComponent(blockTop);

      blockContent.setWidth("100%");

      beanBlock.addComponent(blockContent);
      return beanBlock;
    }