Is it possible to change the grid system for different components? - sitecore

Is there any way for me to change which grid system will each component use. The reason for this is because I want Bootstrap 4 custom on some components, and the regular Bootstrap on another component.
Here is the image to show you what I mean by this:
So is this possible or not? Or every component needs to use just a single one.

Related

Allow user to choose from different Tile Sources in osmdroid

I want to add a map chooser to my osmdroid app, so the user can choose different map types at runtime (e.g. mapnik, Bing maps, opencyclemap etc). Similar to the way you can do that in other map applications e.g. Google maps, leaflet etc.
Does osmdroid provide a UI out-of-the-box to do this? Or do I have to build the UI myself?
I have searched online and couldn't find any mention of anyone wanting to do this. It seems like it would be a very common use case.
For example, leaflet (the browser version) allows you to pass in an array of tilesources, and it automatically adds a dropdown to the map that lets you choose which map to display.
As far as I can tell, MapView only has a setTileSource(ITileSource) method.
Just to be clear, I don't want to display two map styles at once. I want the user to be able to choose from a list of tile sources.
You are correct about setting tile sources, but you do have to build your own UI for it, if you want to allow the user to change it at runtime

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

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.

testing a component with complex angular components nested inside using PageObjects

Our Application has components which consume components with consume components of varying complexity. So i just want the input on the page, to validate when an object is set that the text is correct. The issue is that it is one of these subcomponents.
My colleague told me that there is 2 ways to do this, The first is to use Page Objects, and Chaining annotation to find it on my page, and then find the next id etc until my input is found. It requires me to look through another teams' Component Markup to narrow it down to the input i want to leverage. I dont believe I should have to go into another component definition, or a definition of a definition to get the appropriate chain to get this arbitrary input. It starts to create issues where if a lateral team creates changes unbeknownst to me, my PO will be broken.
The other option my friend asked was to use fixture.query to find the component. This would be as simple as:
fixture.query((el)=> el.attribute["id"] == "description",
(comp){
expect(comp.value, value);
});`
Using Query looks at the markup but then will automatically componentize it as the appropriate SubComponent. In this case, comp.value is the value stored in the HTML. So, if i did something like:
fixture.update((MainComponent comp) {
comp.myinput.value = new Foo();
});
Then I am setting and getting this programmatically, so i am a bit unsure if it properly would reflect what is on the screen.
Whats the best course of action? It seems PO would be better, but im not sure if there is a way around having to deep query for input boxes outside of the component i am testing.
Thanks
I don't think I have a definitive answer for you but I can tell you how we do it at Google. For pretty much any component we provide the page object alongside the component. This is twofold it is for testing that widget, and also so we can have this as a shareable resource for other tests.
For leaf widgets the page objects are a little less fleshed out and are really just there for the local test. For components that are shared heavily the page object is a bit more flushed out for reusability. Without this much of the API for the widget (html, css, etc) we would need to consider public and changes to them would be very hard (person responsible for making the public breaking change needs to fix all associated code.) With it we can have a contract to only support the page object API and html structure changes are not considered breaking changes. At times we have even gone so far as to have two page objects for a widget. One for the local test, and one to share. Sometimes the API you want to expose for a local test is much more than you want people to use themselves.
We can then compose these page objects into higher level page objects that represent the widget. Good page objects support a higher level of abstraction for that widget. For example a calendar widget would let you go to the next/previous month, get the current selected date, etc. rather than directly exposing the buttons/inputs that accomplish those actions.
We plan to expose these page objects for angular_components eventually, but we are currently working on how to expose these. Our internal package structure is different than what we have externally. We have many packages per individual widget (page_objects, examples, widget itself) and we need to reconcile this externally before we expose them.
Here is an example:
import 'package:pageloader/objects.dart';
import 'material_button_po.dart';
/// Webdriver page object for `material-yes-no-buttons` component.
#EnsureTag('material-yes-no-buttons')
class MaterialYesNoButtonsPO {
#ByClass('btn-yes')
#optional
MaterialButtonPO yesButton;
#ByClass('btn-no')
#optional
MaterialButtonPO noButton;
}

django-cms placeholder rendering

Is it possible to loop over the plugins in a placeholder? I want to assign each second plugin another class, so the plugins with an "odd number" appear on the left side and the other on the right sites. Is this possible or do I have to right two different plugins?
Good question. It's possible to modify the content of a placeholder programmatically, but I don't know of a way to get to the individual plugins. See http://docs.django-cms.org/en/2.1.3/extending_cms/custom_plugins.html#plugin-context-processors for more info on how to write a custom plugin processor.
You could probably use BeautifulSoup to add the classing you need to the HTML in this fashion.
Another option would be to add the classing via JavaScript, but you would have a slight delay from the time the DOM is rendered until the classing is applied.

How can I visually design a component in C++ Builder?

I have been away from C++ for a couple of years now doing AS3/Flex work. I have gotten used to being able to create a component and place it in design mode with very little fuss and I am struggling to get my head around the C++ Builder way of doing the same thing.
I have written many components for C++ Builder in the past, but none of them have been visual. What I would like to do now is create a component for customer search and another for order processing because I want to be able to create a new instance of these on the fly. What I don't want to do is have to place each of the components like the dbgrid and search fields manually in code. I would like to do this (as well as set their properties) in design mode.
How do I go about this? I have browsed the source for other Delphi components and I notice they have dfm files which seems to be what I need. How do I do this in C++ Builder? The only option I see is to add a new form if I want a dfm, but this isn't what I want as my components will be based on TPanel.
Is there a way to do this or do I have to resort to doing it all in code with no visual reference?
Pursuing the DFM idea I did a test this morning where I created a component based on TPanel and added a new form to it which I create and parent in the constructor of the component. In design mode I set the form border to none and placed a grid on it. This all looks OK until I place the component in my application, at that point it looks like a panel with a standard looking form in it and the grid is missing. If I run the app the panel shows as expected, borderless and with a grid. The DFM appears to be ignored in design mode for some reason.
If you know a better way to do this than using components then please give me some pointers.
Any help and advice will be appreciated beyond words
You might want to have a look at frames (look for "Frame objects"). They are "subforms" you can design visually and then place on forms.
Just as an FYI item, you can also drop the panel on a form, put any other controls on it, position them, set captions, etc..
Now, click the panel to select it, and use Component->Create Component Template from the IDE's main menu. This creates a unit you can install as a component which will add the panel and it's sub-controls (as a single component) to the IDE's component palette.
Of course, you can then modify the source for that new component like any other component source.