SAPUI5 How to realize a Threshold-Slider (like in WebDynpro) - css

I am currently facing the challenge to realize a Slider in SAPUI5 exactly like the Threshold-Slider from Webdynpro, which looks like this.
How would you do this? It is highly dynamic, the scale (can be 5 values, can be 3 values etc), the descriptions are depending on the scale value ...
Currently I only find Slider in API, but I doubt this is realizable with it ... any ideas?
18.06.2015: currently I am working on extending the sap.ui.commons.Slider, what I got right now is far away from what I try to achieve:
When clicking on slider, Change Background Color via renderer (each value should have another Color
Textfield on the right-hand side and a link on the left side (optional parts, coloring is more important)
What i got...
sap.ui.commons.Slider.extend("my.Slider", {
renderer : {
renderInnerAttributes : function(oRm, oControl) {
console.log(oRm); // try to find out, what I re-style
console.log(oControl); // try to find out, what I re-style
oRm.addStyle('background-color', '#ffff00'); // no effect
},
}
});
var oSlider6 = new my.Slider({
id : 'Slider6',
tooltip : 'Slider6',
width : '500px',
min : 1,
max : 4,
value : 0,
totalUnits : 4,
smallStepWidth : 1,
stepLabels : true,
labels : [
"Bad", "Medium", "Good", "Very Good"
]
});
return oSlider6;

I think the easiest way to achieve this is to either copy the sap.m.Slider and modify it or to inherit from sap.m.Slider with the UI5 extend mechanism and overstyle it. Or you could extend the sap.m.ProgressIndicator and make it interactive but that would be a bit more work.
All the basic functionality is already there in the slider (scale, number of values, ...) and you can easily modify the background color and the styling of the handle. A link a textual value can be added with a label control next to it.
Check this youtube video on custom controls for more details on how to use the extension mechanism of UI5:
https://www.youtube.com/watch?v=4KPS2-LHoO0
Hope that helps,
Michael

you could also choose a d3js control. Either way would take some changes. You can add a style in the xml view. By adding css in your css file you could make them visually the same as your desired controls. The slider has min, max and step by default.
In the change event you could add or remove style classes (addStyleClass/removeStyleClass) to show different colors.
The text you could show seperately and handle with formatters.
If you want it all in one control, you should review this page.

Related

How to combine PrimeFaces InputGroup with an overlay SelectOneButton

I want to build a component, based on InputGroup, with a button that should open a selection. Something more o less like this (please, ignore black border):
When InputGroup p:button A (label '=') is clicked, it opens a p:selectOneButton B, so I can change A value based on B selection.
I have a basic functional script, it can be enhanced, but the simple behavior is accomplished, please fill free to make any improvements/suggestions:
function changeSelectedFilter(evtTarget, tgtButton) {
const op = evtTarget.getJQ().find(':checked').val();
const A = PrimeFaces.getWidgetById(tgtButton);
A.value = op;
A.getJQ().children().text(op);
}
My major issue is with components usage and placement. I'm working with a p:tooltip for now, but it's not what I want, do you have any clues in how to hide/show B correctly placed above A and centered, so it looks like it is been expanded?
With accessibility concerns, this could not be a good approach, and p:menuButton/p:splitButton would be much better, but I want a simple button with just an icon (not default chevron down) and no text...
Here a comparison with p:splitButton and p:menuButton, with desired max-width:
Context: this is a numeric filter component added to columns in p:dataTable, this component current implementation uses a separated p:input and p:selectOneButton, but in 2 lines, so an overlay could optimize space.
Any suggestion with others components will be welcomed too!
Thanks!

How to add opacity transition for mapbox symbol layer

I have a mapbox layer (created in studio) with different icons based on data conditions. Now I'm adding a toolbar to show and hide various icons based on the filter. This works great, but I want to adjust the transition to make it a bit smoother.
I've read some posts about icon-opacity-transition, but it didn't work for me.
map.setPaintProperty('layer-name', 'icon-opacity-transition', { "duration": 300 } );
results in cannot read property 'value' of undefined
Is it possible to change the icon-opacity transition or is it at least possible to show and hide a layer with some custom transition values?
Not sure if this will help you still, but it was very important for our project. Its a 'global map property' called 'fadeDuration'...
new mapboxgl.Map({
fadeDuration: 0,
...
})
I'm not sure about accessing by layer though...
https://github.com/mapbox/mapbox-gl-js/issues/6519#issuecomment-390001993

Create Profile Dropdown Menu in Polymer with Triangular top

I am trying to create a profile menu for my polymer website, something on the lines of github.com
If you notice,there is a triangular tip at the top of the menu.I am trying to create a similar triangle at the top of paper-listbox.
The problem I am facing is that the triangle seems to hide as soon as it gets out of the boundaries of paper-listbox.
I have create a jsbin to demonstrate my problem: http://jsbin.com/samaloqowu/1/edit?html,console,output
If you change the top property of the triangle (say -16px), it hides when it gets out of the listbox region. Please help me solve this CSS issue.
Short answer : No you can't.
Explanation : Because the dropdown content get encapsulated in a slotted element that gets styled inside the shadowRoot of the custom element you try to modify the behavior. And the paper-menu-button doesn't actually gives you a way to directly customize the slotted.
But there is a trick ! You can access the slotted through classic javascript. Just alter your connectedCallback function and add this line :
...
connectedCallback() {
super.connectedCallback();
this.$.profileMenu.$.dropdown.querySelector('.dropdown-content').style.overflow = 'visible';
...
}
...
This should do the trick, I agree this looks totally awful and trying to force and change the initial behavior of an element is not really recommended but well it seems to work, just make some tests when the element gets in a new context to see if anything breaks.
UPDATE (22/09/2017) :
Thinking of that again, I think this is a terrible idea to change this overflow to visible, I guess the polymer team has set the overflow to auto because if the list get long and you force the height of the element, the list will flow and be visible which is not really a dropdown anymore, but more like a full list display and that will mess with the general design purpose of your app. IMO when you start trying to mess with the inner properties of a custom element it means this element doesn't quench your requirement, and that it's time to make your own, especially when you try to modify the design of a custom element that has a design already implemented.

Cloning parsys component functionality

I wish to take the component libs/foundation/components/parsys/colctrl/... and modify its text so that I can use it for css tabs instead. I recreated it as apps/-site-/components/content/tabsys/ (and all it's subfolders/components/etc. The only thing I didn't change was in tabsys/tabctrl/virtual/2tabs/cq:editConfig/cq:formParameters (same for 3tabs/ as well):
sling:resourceType = foundation/components/parsys/colctrl
layout = 2;cq-colctrl-lt0
In the sidekick I now have a Tabs component option, with the same options as Columns. However, when I drag any of the Tabs into the content area, I don't get any of the border content areas to drag content pieces into; only the Edit/Delete/New bar. When I click Edit I should have a dropdown for the number of columns I want to have (Columns component has it for reference). What am I missing?
I ran into this same issue, and the reason for this seems to be that the ParagraphSystem class used by the parsys component only parses/generates the columns/containers if the sling:resourceType of the content node ends in "/colctrl".
private String colCtrlSuffix = "/colctrl";
if (res.getResourceType().endsWith(this.colCtrlSuffix)) { /*creates columns*/ }
In your example, the tabctrl should have a reference to the Super type:
sling:resourceSuperType = "foundation/components/parsys/colctrl"
Secondly, if tabctrl were renamed to colctrl then the ParagraphSystem would attempt to parse the columns based on the number specified in first part of the layout attribute and create the additional content nodes for each column.
If the ParagraphSystem class looked for "-colctrl" rather than "/colctrl" it would have allowed for customized components like "my-colctrl". Instead, I guess we need to use folders to avoid naming collisions. (i.e., apps/-site-/components/content/tabsys/colctrl)

how to code NSButton to look just like image

Using code (not the Interface builder) I need to create an NSButton that looks like an image. Specifically I want to use NSImageNameStopProgressFreestandingTemplate and I need it not to look like button but to look like the image. This means:
1. No 'button down' look
2. No border, no any visibility of the button
Thanks.
I know this response is a bit late, but you could try this, given thisButton:
[thisButton setImage:[NSImage imageNamed:NSImageNameStopProgressFreestandingTemplate]];
[thisButton setImagePosition:NSImageOnly];
[thisButton setBordered:NO];
That last line is the key bit: removing the button border effectively strips it of its bezel, leaving only the image to click on. (BTW, I haven't tried the above code specifically, so you may need to throw in a couple of other tweaks, such as setting the imageScaling or buttonType, to get it to work best.)
One final note: If you're using a template image (as you said you would), Cocoa will automatically display it with a slight dark-grey gradient; when the button is clicked, it will momentarily darken to solid black. This is an automatic "'button down' look" you didn't want; however, it is very subtle, and is a good indicator that the button worked. If you don't want this to happen, you could get an instance of the desired image and [stopImage setTemplate:NO]; on it.
Disable isBordered
let button = NSButton(
image: NSImage(named: NSImage.Name("plus"))!,
target: self,
action: #selector(onButtonPress)
)
button.isBordered = false
If you don't want to use a templated but want the push down highlight anyways, you can also use the following setup for an NSButton:
let imageButton = NSButton()
imageButton.image = NSImage(named: "MyImage")!
imageButton.bezelStyle = .shadowlessSquare
imageButton.isBordered = false
imageButton.imagePosition = .imageOnly
The important thing to make the highlight work on any image is to set bezelStyle to shadowlessSquare.
I know this behavior wasn't requested in the question, but it might be useful for others.

Resources