CKEDitor: show / hide items by menu group - menu

I have a context menu in CKEditor 4 with many items, that I hide or show based on the divs' classes. I tried to show and hide items by menu group, e.g.
editor.addMenuGroup('odt') ;
editor.addMenuItem('item_1', {
label: 'Item 1',
group: 'odt',
order: 100,
command: command_1,
} ;
// More items follow...
editor.contextMenu.addListener(function(element, selection, path) {
let rv = {} ;
// The following is just an example, my logic is more involved
rv['odt'] = CKEDITOR.TRISTATE_OFF ;
return rv ;
}) ;
This doesn't work, i.e., the items belonging to the group I return from the listener are not added to the menu.
Debugging the problem I found out with surprise that the group field in the menuItems inside the editor is set to the menu order, for example
>> Object.entries(CKEDITOR.instances)[0][1]._.menuItems.item_1.group
100
Digging in the code, I found the following surprising lines in ckeditor4/plugins/menu/plugin.js:
CKEDITOR.menuItem = CKEDITOR.tools.createClass( {
$: function( editor, name, definition ) {
[...]
// Transform the group name into its order number.
this.group = editor._.menuGroups[ this.group ];
Therefore, even without knowing if setting CKEDITOR.TRISTATE_OFF on the group name would work, I know for sure that the group name will not be used.
Am I missing something?
Did anybody ever manage to show / hide menu items in CKEditor 4 by menu groups?
Why the group name is transformed to group order in the internal data???

Related

Hide empty section in Compositional Layout Collection View with DiffableDataSource not working

I have three sections of data on screen: one for Five Star Items, one for Visits, and one for Other Fun Places items. They are all of the same type: funPlaces. For this example, I'm creating three arrays of funPlaces and showing them in three sections.
What I'd like to do is not generate a section on-screen at all if there is no data available for that section. So if there is no Visits data, I only want to see the sections for Five Star Items and Other Fun Places items. If there are no Five Star Items, I only want to see the sections for Visits and Other Fun Places items, etc.
However...
What's happening is that if there are no Visits items for example, rather than the Visits section disappearing as I would expect, instead the data from otherFunPlaces gets shown in the Visits section on-screen and the entire Other Fun Places section disappears. Yes, the Visits data is gone, but the section is still there and its data has been replaced with Other Fun Places data on-screen.
If I have an empty Five Star Items array, the Five Star Items section is still shown but the data has been replaced with Visits data on-screen. And the Other Fun Places data shifts up a section to the Visits Section--it's the Other Fun Places section that actually disappears on-screen.
The only case that works is if I have an empty Other Fun Items array--the section disappears as expected, and the data in the two sections above is also in its proper place on-screen.
What am I missing to make this work?
func applySnapshot(animatingDifferences: Bool = true) {
let funPlaces = fetchedResultsController.fetchedObjects ?? []
if funPlaces.count > 6 {
// we only generated enough sample data objects in viewDidLoad for this test
// we're going to make sure there are no fiveStarItems in the array for this test
// let fiveStarItems = Array<FunPlace>(funPlaces[0...1])
let fiveStarItems: [FunPlace] = [] // hide fiveStarItems
// we're going to keep data in visitsItems and otherItems
let visitsItems = Array<FunPlace>(funPlaces[2...3])
let otherFunPlacesItems = Array<FunPlace>(funPlaces[4...5])
var snapshot = NSDiffableDataSourceSnapshot<Sections, FunPlace>()
if !fiveStarItems.isEmpty {
snapshot.appendSections([Sections.fiveStar])
snapshot.appendItems(fiveStarItems, toSection: .fiveStar)
}
if !visitsItems.isEmpty {
snapshot.appendSections([Sections.visits])
snapshot.appendItems(visitsItems, toSection: .visits)
}
if !otherFunPlacesItems.isEmpty {
snapshot.appendSections([Sections.otherFunPlaces])
snapshot.appendItems(otherFunPlacesItems, toSection: .otherFunPlaces)
}
dataSource?.apply(snapshot, animatingDifferences: true)
}
}
Thanks.
When creating the layout make sure you do it based on the section identifier, not the section number. This way, any section with no data will not be displayed:
let layout = UICollectionViewCompositionalLayout(sectionProvider: { sectionNumber, env in
let sectionIdentifier = self.dataSource.snapshot().sectionIdentifiers[sectionNumber]
if sectionIdentifier == .fiveStar {
return FiveStarSectionLayout....
} else if (sectionIdentifier == .visits) {
return VisitsSectionLayout....
} else if sectionIdentifier == .otherFunPlaces) {
return OtherFunPlacesSectionLayout...
} else {
return nil
}
})
self.collectionView.setCollectionViewLayout(layout, animated: true)
I figured it out.
The problem was indexing the sections to lay out. I had to keep track of available sections separately and only lay out the ones available.

Acumatica Mobile - Is it possible to make a Container with a value of a field displayed together with the container name?

I'm new to Acumatica and I was wondering if this is possible to make in Acumatica Mobile App.
I have created 3 custom fields in the Customer screen where it can calculate the total amount of AR Invoices, Hold Checks, and Voided Payments of the customer.
I want it to be displayed in mobile app just like the images I have attached.
The first image I have attached shows where the Customers list and it should display the Name of the Customer together with the TotalARBalance field. The second image shows if you select a specific Customer it will display its total amount of TotalARBalance, TotalHoldBalance, and TotalVoidedBalance with its Container Name accordingly.
This is the Customers screen in Web App:
This is my code for the Customers screen:
add screen AR303000 {
add container "CustomerSummary" {
add field "CustomerID"
add field "Status" {
forceIsDisabled = True
}
}
add container "ARInvoice" {
add field "RefNbr"
add field "Status"
add field "Balance"
add field "DueDate"
}
add container "HoldChecks" {
add field "PaymentRefNbr"
add field "DateOfHold"
add field "PaymentAmount"
add field "ExtensionDate"
}
add container "VoidedPayments" {
add field "ReferenceNbr"
add field "VoidStatus"
add field "PaymentAmount"
add field "DateVoided"
}
}
I tried to look in the Documentation for Mobile Framework Guide but I found nothing similar to what I want to make
I think you have two questions here:
Adding the TotalARBalance custom field to the Customer List Screen (AR3030PL).
-Make sure the TotalARBalance custom field is visible in the UI web screen.
-Get the proper name to be used in the MSDL Code (Mobile customization) for this field. In order to do this you must check the WSDL Schema for that screen (AR3030PL).
-Then make sure that you set the proper value to the fieldsToShow property for your Result container, see below:
add screen AR3030PL {
add container "Result" {
fieldsToShow = 5
containerActionsToExpand = 2
add field "Field1"
add field "Field2"
add field "Field3"
add field "Field4"
add field "TotalARBalance"
add containerAction "editDetail" {
behavior = Open
redirect = True
}
add containerAction "Insert" {
icon = "system://Plus"
behavior = Create
redirect = True
}
}
}
About the container with custom field's values.
Out of the box I don't think the Mobile app could render the exact same design.
You could create a group with the same names as you showed in your image but the field's value won't be displayed when the group is collapse. However, if the user uncolpases the group then they will be able to see the custom field's value for that group.
See below quick snippet for the AR Invoice group in your image:
................
add group "ARInvoiceGroup" {
displayName = "AR Invoice"
collapsable = True
collapsed = True
add field "TotalARBalance"
}
#add other two groups here
........
You can review more information about groups on this help article below:
https://help.acumatica.com/(W(1))/Help?ScreenId=ShowWiki&pageid=37c0e79c-e89e-4e41-8b05-ca3df5e053f1

Select UI Element by filtering properties in coded ui

I have a web application. And I am using coded ui to write automated tests to test the application.
I have a dropdown with a text box. Which on entering values in the textbox, the values in the dropdown gets filtered based on the text entered.
If I type inside textbox like 'Admin', I will get below options like this:
And I need to capture the two options displayed.
But using IE Developer tool (F12), I am not able to capture the filtered options, because the options that are displayed do not have any unique property (like this below). And the options that are NOT displayed have a class="hidden" property
Any way to capture the elements that are displayed by applying some kind of filter like 'Select ui elements whose class != hidden'
Thanks in advance!!
HI please try below code will it works for you or not.By traversing all those controls that have class ="hidden"
WpfWindow mainWindow = new WpfWindow();
mainWindow.SearchProperties.Add(HtmlControl.PropertyNames.ClassName, "hidden");
UITestControlCollection collection = mainWindow.FindMatchingControls();
foreach (UITestControl links in collection)
{
HtmlHyperlink mylink = (HtmlHyperlink)links;
Console.WriteLine(mylink.InnerText);
}
I'm not sure there is a way to do it by search properties, but there are other approaches.
One way would be to brute force difference the collections. Find all the list items, then find the hidden ones and do a difference.
HtmlControl listControl = /* find the UL somehow */
HtmlControl listItemsSearch = new HtmlControl(listControl);
listItemsSearch.SearchProperties.Add(HtmlControl.PropertyNames.TagName, "li");
HtmlControl hiddenListItemsSearch = new HtmlControl(listControl);
hiddenListItemsSearch.SearchProperties.Add(HtmlControl.PropertyNames.TagName, "li");
hiddenListItemsSearch.SearchProperties.Add(HtmlControl.PropertyNames.ClassName, "hidden");
var listItems = listItemsSearch.FindMatchingControls().Except(hiddenListItemsSearch.FindMatchingControls());
You will only be able to iterate this collection one time so if you need to iterate multiple times, create a function that returns this search.
var listItemsFunc = () => listItemsSearch.FindMatchingControls().Except(hiddenListItemsSearch.FindMatchingControls());
foreach(var listItem in listItemsFunc()){
// iterate 1
}
foreach(var listItem in listItemsFunc()){
// iterate 2
}
The other way I would consider doing it would be to filter based on the controls which have a clickable point and take up space on the screen (ie, not hidden).
listItemsSearch.FindMatchingControls().Where(x => {
try { x.GetClickablePoint(); return x.Width > 0 && x.Height > 0; } catch { return false; }
});

Drupal 6 - Passing variable between functions specifically - Passing menu name to phptemplate_menu_item

I'm quite new to Drupal 6 and theming it. My theme required the main menu to pump out quite extensive html/css for my reasonably involved styling. To achieve this I pieced together this code 'function phptemplate_menu_item' (see bottom) which sits in my template.php and produces different html depending on the whether the menu item has children or not and uses the contents of the link to generate a css class.
My problem is that this code is also being applied to my other menus. I would like make the menu_item generate different html depending on whether it is in the primary-menu or not. I would have thought that the easiest way to do this is with an if statement in the function phptemplate_menu_item, for example:
function phptemplate_menu_item (...){
if ($menu_name == 'primary-links')
{DO ABC}
else
{DO XYZ}
}
However I believe I need to know how to pass the menu name to the phptemplate_menu_item function. Any help with this would be really appreciated as I have been banging my head against the wall trying to solve this for some time now.
Thanks!
function phptemplate_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
$class = ($menu ? 'no_wrap' : ($has_children ? 'collapsed' : 'li_wrap'));
if (!empty($extra_class)) {
$class .= ' '. $extra_class;
}
if ($in_active_trail) {
$class .= ' active-trail';
}
if (!empty($link)) {
/* The following section gives the list items unique classes based on their link text - note how spaces and sepcial chars are removed */
// remove all HTML tags and make everything lowercase
$css_id = strtolower(strip_tags($link));
// remove colons and anything past colons
if (strpos($css_id, ':')) $css_id = substr ($css_id, 0, strpos($css_id, ':'));
// Preserve alphanumerics, everything else goes away
$pattern = '/[^a-z]+/ ';
$css_id = preg_replace($pattern, '', $css_id);
$class .= ' '. $css_id;
}
// the following code returns the menu item formatted in a different fashion depending on the class of the item. The first one is for items with a class of none - ie the space li at end of menu
if (strstr($class, 'none')) {
return '<li class="'. $class . ' main"></span></span></li>';
}
if (strstr($class, 'li_wrap')) {
return '<li class="'. $class .' main"><span class="wrapped">'. $link . $menu ."<span class='indicator'></span></li>\n";
}
if (strstr($class, 'no_wrap')) {
return '<li class="'. $class . ' main">'. $link ."<span class='indicator'></span><span class='menu_box'><span class='menu_box_inner'>". $menu ."</span></span></li>\n";
}
}
Well I think the solution found here it's the best so I'm not going to take credit for it. Instead of overwriting theme_menu_item you should define your custom function theme_primary_links starting from theme_links.You can choose whatever name you think it's best for your custom theme (but make sure that it's not already used).
Bottom line: sometimes it's easier to define your custom theme than overwriting the default ones. That way you know that you can strictly apply the custom theme according to your needs (e.g. applied only to the primary menu links). Overwriting is best used when you want your changes to be global (e.g. applied to all menu links).

How to get string value from mfc popupmenu when clicked without making use of resource id

I'm creating a dynamic popup menu without generating resource ids. How can I keep track of the clicked action without a resource id?
Is there any way I can get menu's string value?
CMenu m_subMenu;
m_subMenu.CreatePopupMenu();
utf16string actionName(L"");
int nCatgryId = 1000;
for( ; itr != itrEnd ; ++itr)
{
actionName = itr->first;
CString csActionName = actionName.c_str();
AppendMenu(MF_STRING,nId++, csActionName);
}
So how do I obtain the value from the menu when an action is clicked?
#define YOURMENU_ID WM_APP+10
...
AppendMenu(.., YOURMENU_ID,...);
And handle it in WM_COMMAND
Every menu item, when you create it, needs to have an ID. You need to reserve a list of ID's, use those to create the menu items, then use the normal menu functions to get information on them.

Resources