Author Topic: Create/add own button to existing view.  (Read 1904 times)

Offline MJaskowski

  • Newbie
  • *
  • Posts: 21
  • Karma: 0
Create/add own button to existing view.
« on: February 26, 2020, 05:54:20 AM »
Hello everyone,

I have question about create/add new button to existing view. Is it possible?

I want add button programatically to ContactInfoHistoryMultiRegion and exactly to ContactInformationView -> DockPanelContactHistoryContent -> Toolbar_Copy. I can't access to it and I don't know how to bite it. Did you have similar case?

Thank you for all tips.

Regards
Matt

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7131
  • Karma: 56330
Re: Create/add own button to existing view.
« Reply #1 on: February 26, 2020, 08:11:48 PM »
Check WDE samples. There is a Button sample.


Enviado de meu SM-N9600 usando o Tapatalk


Offline MJaskowski

  • Newbie
  • *
  • Posts: 21
  • Karma: 0
Re: Create/add own button to existing view.
« Reply #2 on: February 26, 2020, 08:31:09 PM »
Hello cavagnaro,

thank you for answer. I know sample with button, I hope we talk about the same sample - I can create buttton in my NEW/OWN view, for example to ToolbarWorkplaceRegion I add new tab with button, right?

But my question is about existing view created default in WDE and more precisly I'm talking about Contacts History Tab. Or maybe I misunderstood you? Could you expand your thought?

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7131
  • Karma: 56330
Re: Create/add own button to existing view.
« Reply #3 on: February 26, 2020, 08:33:05 PM »
Yeah, same, just get the View name, also at Documentation, and elaborate into that.


Enviado de meu SM-N9600 usando o Tapatalk


Offline MJaskowski

  • Newbie
  • *
  • Posts: 21
  • Karma: 0
Re: Create/add own button to existing view.
« Reply #4 on: February 27, 2020, 01:03:33 AM »
Cavagnaro,

I suppose to do something wrong or I don't know about any method. I found where is my problem, I'm adding new ViewActivator to ContactTabBottomHistoryMultiRegion but this region doesn't exist yet when ExtensionModule do Initialize() method.

Code: [Select]
public void Initialize()
{           
     container.RegisterType<IMyView, MyView>();
     container.RegisterType<IMyViewModel, MyViewModel>();
}


then I made viewEventManager.Subscribe(CheckingEvent) which raise event after select email in ContactHistoryView

Code: [Select]

private void CheckingEvent(object obj)
        {
            string loadedAction = (obj as GenericEvent).Action[0].Action as string;
            ViewActivator toolbarContainer = null;

            if (loadedAction == "LoadInteractionInformation")
            {
                foreach (ViewActivator view in viewManager.ViewsByRegionName["ContactInfoHistoryMultiRegion"])
                {               
                    if (view.ViewName == "ContactInformationView")
                    {
                        viewManager.ViewsByRegionName["ContactTabBottomHistoryMultiRegion"].Add(
                               new ViewActivator()
                               {
                                   ViewType = typeof(IMyView),
                                   ViewName = "MyView",
                                   ActivateView = true
                               }
                         );                     
                        break;
                    }
                }
            }           
        }


ViewActivator correctly add to region but unfortunately I don't see result. If I will add the same view to eg. ToolbarWorkplaceRegion, I see my view. I can't catch what is point.

Should I do it any other way?







Offline Kubig

  • Hero Member
  • *****
  • Posts: 2625
  • Karma: 41
Re: Create/add own button to existing view.
« Reply #5 on: February 27, 2020, 01:11:08 AM »
I do not see any reason for iterating the existing view. You can directly add your custom view into existing region through the ViewManager. You just need to load your module after the ContactModule is loaded, thus why you cannot insert view right now as you trying to insert it so early.

I use ContactTabBottomHistoryMultiRegion region is several projects and never have encountered any issue on that.
Genesys certified professional consultant (GVP, SIP, GIR and Troubleshooting)

Offline MJaskowski

  • Newbie
  • *
  • Posts: 21
  • Karma: 0
Re: Create/add own button to existing view.
« Reply #6 on: February 27, 2020, 01:58:45 AM »
My guess is I try too early to load my view that's why I made own event but this is wrong way. Did you do the same way or do you load view by other method? I can't catch where I am wrong.
Any keywords?

If I add ViewActivator by own event (when I have and I see ContactInfoHistoryMultiRegion region) then my view isn't visible, should I use any method or something yet?
« Last Edit: February 27, 2020, 02:10:15 AM by MJaskowski »

Offline MJaskowski

  • Newbie
  • *
  • Posts: 21
  • Karma: 0
Re: Create/add own button to existing view.
« Reply #7 on: February 27, 2020, 05:37:13 AM »
Quote
You just need to load your module after the ContactModule is loaded

How can I catch it? By event? Could you expand thought?



Offline PeteHoyle

  • Full Member
  • ***
  • Posts: 119
  • Karma: 11
Re: Create/add own button to existing view.
« Reply #8 on: February 28, 2020, 12:08:45 AM »
Hi Matt,

In initialize method try using the viewManager.AddViewsToRegion method, then you don't need to wait for the region to already exist:


Code: [Select]
            viewManager.AddViewsToRegion("ContactTabBottomHistoryMultiRegion", new List<ViewActivator>() {
                new ViewActivator()
                {
                    ViewType = typeof(ICancelRecordView),
                ViewName = "MyView",
                ActivateView = true,
                ActivateOrder = 30
                }

            });

Offline MJaskowski

  • Newbie
  • *
  • Posts: 21
  • Karma: 0
Re: Create/add own button to existing view.
« Reply #9 on: February 28, 2020, 12:39:02 AM »
Pete!

You are an amazing guy! Thank you so much. Such a small change, and allowed me to do it the way I wanted. I understand that the AddViewsToRegion method creates a non-existent region? Something like a placeholder?

Thank you for your knowledge, again!


Matt

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7131
  • Karma: 56330
Re: Create/add own button to existing view.
« Reply #10 on: February 28, 2020, 01:03:38 AM »
Pete is THE guy

Enviado de meu SM-N9600 usando o Tapatalk


Offline Kubig

  • Hero Member
  • *****
  • Posts: 2625
  • Karma: 41
Re: Create/add own button to existing view.
« Reply #11 on: March 02, 2020, 09:05:36 PM »
Honestly, I am using both approaches (using AddViewsToRegion and ViewsByRegionName methods) and never have encountered issue with instanting custom view/part. I suppose there might be another issue that causes your custom part is not visible at all.
Genesys certified professional consultant (GVP, SIP, GIR and Troubleshooting)

Offline MJaskowski

  • Newbie
  • *
  • Posts: 21
  • Karma: 0
Re: Create/add own button to existing view.
« Reply #12 on: March 03, 2020, 09:43:08 PM »
I don't know why the .Add () method for viewManager did not work for the region "ContactTabBottomHistoryMultiRegion". I checked the "ToolbarWorksheetRegion" region and it works fine.

The .AddViewsToRegion () method works well in both cases. Everything is located in the main module Initialize() loaded at startup (the same as ExtensionSampleModule). Maybe it's a bug? Have I implemented something bad maybe? But I didn't create something special, so I don't think so. Any idea what could I check?

Offline Kubig

  • Hero Member
  • *****
  • Posts: 2625
  • Karma: 41
Re: Create/add own button to existing view.
« Reply #13 on: March 03, 2020, 11:18:05 PM »
Which version of IWS/WDE are you using?
Genesys certified professional consultant (GVP, SIP, GIR and Troubleshooting)

Offline MJaskowski

  • Newbie
  • *
  • Posts: 21
  • Karma: 0
Re: Create/add own button to existing view.
« Reply #14 on: March 03, 2020, 11:22:20 PM »
WDE 8.5.127.06