Is it possible to write a simple custom link that shows or hides all layers on a page? - draw.io

I have a draw.io diagram page consisting of over 40 layers. But because I don't know which layers the user will have hidden/shown on the published diagram, I want to provide a button with an action set that hides all layers, then shows 3 specific layers.
Is it possible to hide all layers using a wildcard or similar, or do I need to manually create a huge (in manual management terms) layer id JSON array?
From what I can tell it's not possible, which surprises me, hence my asking. For my diagram it means I need to maintain huge JSON arrays in many links.
I've tried various custom links using cell and tag action wildcards, but my tests suggest tags only work for shapes (not layers), and cells includes both shapes AND layers.
data:action/json,{"actions":[{"hide":{"cells":["*"]}}]}
I hoped using the above custom link would cause all layers to be hidden, which it did, but it also caused shapes on the currently selected layer to be hidden. It also caused shapes on the currently selected layer to appear deleted within the editor, so I needed to use the Undo feature to get the shapes back. I guess this is a bug, unless I'm doing something wrong or my drawing has become corrupt.
Something like this would be a really useful feature:
data:action/json,{"actions":[{"hide":{"layers":["*"]}}]}
I would consider writing a plugin, but can't find any help documentation on the subject. Could someone advise on this?

It is possible to add tags to a layer. In order to do this, edit layer data (click on the layer, then on the three vertical dots) and add the "tags" property:
Add "tags" property to layer
Afterwards, you'll be able to add a tag to the layer like this:
Add tag "some_tag" to the layer
Now you can show or hide all layers with the tag some_tag with the following custom links:
Show all layers with some_tag:
data:action/json,{"actions":[{"show":{"tags":["some_tag"]}}]}
Hide all layers with some_tag:
data:action/json,{"actions":[{"hide":{"tags":["some_tag"]}}]}

I worked around the problem of not being able to hide all layers on a page via wildcard by using tags.
It's possible to tag individual shapes, or by grouping shapes and adding the tags property at the group level. So long as a shape or group has a "tags" property in the "Edit Data" screen with a value in it, it's possible to hide all by using the following custom link:
data:action/json,{"actions":[{"hide":{"tags":[""]}}]}
The same for showing all tags on a page:
data:action/json,{"actions":[{"show":{"tags":[""]}}]}
To show everything on a page without using tags it's possible to just use:
data:action/json,{"actions":[{"show":{"cells":["*"]}}]}
I also needed to add two buttons to an admin layer:
A "reset" button with "hide"/"show" custom link actions to reset the diagram to an initial state.
A "show all" button with "show" custom link actions to get all the shapes visible again, otherwise it wasn't possible to access them when editing the diagram.

Related

Sitecore 8 implement tooltip on RTE authored content

We have a requirement to implement tooltips for words that are authored in Sitecore RTE.
The idea behind is that user should be able to hover over the word and see it's description/meaning.
Is this possible to achieve in sitecore? Did a quick search on marketplace but could not find any modules.
Below are some options to consider for achieving what you described.
Inject Tooltip HTML in a renderField pipeline
In this option, you would extend the renderField pipeline. First, you will need to ensure that you are dealing with a rich-text field, and if so, locate terms and replace them with the necessary markup that is required for the tooltip. This could be as simple as wrapping the word in an <abbr> or perhaps a <span> element with a CSS class. The list of terms and tooltip content could be sourced from items in Sitecore or a custom Sitecore Dictionary. Caching the terms would be essential as this pipeline processor is invoked frequently every time a field is rendereded.
Progressive enhancement with JavaScript
This approach is almost entirely based on the client-side. Terms could be located and replaced fairly easily with the help of JQuery. If the list of terms is of a reasonable size, they could be bootstrapped into a JavaScript variable. Once terms are located and enhanced, a separate, asynchronous call to a REST endpoint could be made when hovering or clicking the term. The API would accept a term and respond with the term's definition.
HTML Snippet in RTE Editor
Sitecore RTE editor can be extended with additional buttons. One of these options allows you to insert predefined snippets of HTML. The RTE editor also has a setting to specify a CSS file to style the content within the field (<setting name="WebStylesheet" value="/css/yourstylesheet.css" />). Styling would be necessary in order to target the description markup and make it visible to be edited, whereas, on the public site, the description markup would normally be hidden by default until the term is clicked on or hovered over.
Dynamic Link Replacement
http://www.layerworks.com/blog/sitecore-token-replacement

Specify order of slides in carousel?

Is there a way to control the order of slides displayed to users in a carousel from the Experience Editor perspective? (or even the Content Editor)
Basically, based on the user that has been identified or not identified, I would like to display a different slide as the first slide of the carousel. All the other slides would still be present, just in a different, specified order.
Is there a way to accomplish this via rules or should I look at having to create separate datasources that have the different slide orders already specified?
TL;DR
Personalization can do three things:
vary a datasource for a rendering
vary a rendering (use another rendering basically)
hide a rendering.
I guess the question you need to answer is whether what you need can be accomplished by doing either one of these actions.
If you've used nested structures to represent your carousel (like we do in SCORE, you can see how it looks like here or here) it's not hard to show/hide certain panels based on personalization conditions and thus reorder the carousel. Depending on how exactly it looks on the published site you may only need to repoint datasources. Either way, it's personalization out of the box and your content structures working nicely together.
If you've used a (variation of a) MultiList field to represent a list of your panels with panels themselves being items somewhere in the shared content area it's not something personalization engine can change based on a condition. Changing a field value is, unfortunately, not on the menu. I am sure you can code around it thanks to Sitecore being so open and flexible but I am not sure you can make it seamless (e.g. variations preview in Page Editor).
Rendering parameters is also not something you can change but if yours are static and defined on the rendering definition item (as opposed to being supplied when component is bound to the placeholder and thus recorded inside the presentation details) you can get away with having two definition items for your carousel component (same code behind it) and picking the right one based on the personalization condition.
Hope it helps.

Sitecore Page Editor issue

I was trying to move components in Page Editor mode , and below are the things I have done to achieve this :
Set Compatible rendering selected for the Sublayouts
Added placeholder settings and allowed controls for placeholders
But , when I was trying to move components, the DataSourceItems for the sublayouts are not changing , hence the content is not changing.
And , also sometime I am getting Field related errors if the fields are different in the DataSources.
Can someone please help me in this .
From your question, it sounds like you are trying to move a component from one placeholder to another in Page Editor. That does not affect the data source.
If instead you mean you are trying to personalize the experience by using rules to switch the data source within a sublayout, the steps you've taken won't allow for that. You need to add conditions to the sublayout in Page Editor to choose which data source you want to display.
If you are trying to have compatible renderings (different sublayouts) show for the same placeholder, that is something that is done by your step 1. This is only to help authors know what other sublayouts would be a good idea to put in that placeholder. It does not affect the data source.
When you add components, the datasource for them is not set automatically. You need to check if it's set and use Sitecore.Context.Item if it's not.
Not sure if that's what you mean..
As for field related errors, please post more details.

Does MFC have a built in grid control?

First what I want: The ability to display a grid with multiple columns, each cell having a custom render callback. So you might use such a control to display your inventory in a game, or something like the behaviour in Google Chrome where it shows a grid of popular pages you visit.
I've been playing with CListCtrl and while I can get custom rendering ability on each item, I can't get it work with columns - having say 3 items per row. The control has column-related methods but I think these are specifically for the built-in functionality where different attributes of an item are shown automatically in each column... not for providing a generic grid control.
So, does such functionality exist in MFC? If not then I wonder if the easiest approach is for me to actually insert each of the rows as an Item... and then the custom rendering draws the multiple cells in the row, I could also do custom UI to support clicking on the cells.
But what I really want is to be able to create a custom control, and add this as an item to a list - like in Flex for instance - so I/O etc is automatically handled.
Any advice/information welcome...
Dundas has thrown some of its (excellent) components in the public domain. Their Ultimate Grid is available on CodeProject.
I'm not aware of a built-in control, but I think you should take a look at this.
The article is describing in detail the functionality of a fully featured MFC grid control, derived from CWnd, for displaying tabular data.
YOUR_LIST_CONTROL.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_INFOTIP|LVS_EX_GRIDLINES);
I think it will help you (SetExtendedStyle).
I suggest this one:
https://code.google.com/p/cgridlistctrlex/
very complete

How to add data Filtering using CListCtrl and CHeaderCtrl

Background:
Applications that manipulate a collection of data typically present using a grid containing a header. These same applications typically incorporate a filter to allow the user to narrow the data set (Excel is a wonderful example. There are many others).
In my MFC application, I'm attempting to do the same using the CListCtrl and CHeaderCtrl combination. This combination has already enabled my application to provide for multiple column sorting including using the Image capabilities of the individual header items to represent ascending/descending sort order.
I have used my best Google-fu to locate any examples where the CHeaderCtrl was extended/customized to include custom drawing to account for the addition of the filter button and display an associated drop menu for user input of filter criteria when clicked.
Question(s):
Are there examples I missed?
If no examples available via the internet, what approach(es) should I consider in customizing CListCtrl and CHeaderCtrl to accomplish my goal?
Additional Comments:
One of the answers referenced the built-in FilterBar functionality. Yes I've seen that but it's not what I'm looking for. I'm looking to specifically emulate the non-static, non-visually intrusive filtering capabilities of Excel and other filter-enabled applications.
My Google-fu confirms yours, no examples that add non-invasive filter interface to CListCtrl, with or without the CHeaderCtrl.
Simple approach
In your HDN_ITEMCLICK handler, check the ((NMHEADER)lParam).iButton. For iButton == 1, that's the right mouse button. Here's your chance to show a little CWnd-dervied filter UI. Problem with this approach is there's no visual indication that right-click will bring up a filter menu.
More complicated
Create three column header images - filter icon, up arrow + filter icon, down arrow + filter icon. When not sorted on a column, show the filter only image, otherwise use the appropriate arrow + filter image. Handle click on the CListCtrl at the NM_RCLICK level so you get coordinate info (example.) Do some geometry to figure out if the click was on your filter icon, if so, show a little CWnd-derived filter UI. You can get even fancier and show the current filter in header tooltips, create more images with colored filters to show when a filter is active.
Is this you are looking for?
Since it is in other language, I have given the googled address. Refer second result.