How to change layout of sap.uxap.ObjectPage Blocks - sapui5

Demo
I have 2 + 5 blocks here, in small screen, each panel in blocks are in full width.
But in large screen, blocks are in 3:3:3 or 6:3. I want them all in a single row.
each section is contained in <div class="sapUiRespGridSpanL4 sapUiRespGridSpanM6 sapUiRespGridSpanS12 sapUiRespGridSpanXL3">
How to change it to class="sapUiRespGridSpanL12 sapUiRespGridSpanM12 sapUiRespGridSpanS12 sapUiRespGridSpanXL12" ?
I've tried to add layout in Panel, but not working.
Refrence:
sap.uxap.ObjectPageLayout Documentation
layout of blocks, blocks are in the same color, hard to specify

Finally after 1.5 hours figured out
Reason: Blocks will have to be extended from BlockBase to apply columnLayout.
Extending the BlockBase:
sap.ui.define(["sap/uxap/BlockBase"], function (BlockBase) {
"use strict";
var BlockPanel = BlockBase.extend("sap.uxap.sample.ObjectPageSubSectionSized.blocks.BlockPanel", {
metadata: {
/* no additional views provided */
}
});
return BlockPanel;
});
Then create a view and controller using the above new ui5 extended control. Use that in your page with columnLayout
xmlns:sample="sap.uxap.sample.ObjectPageSubSectionSized.blocks"
...
...
<uxap:blocks>
<sample:BlockPanel columnLayout="4"/>
</uxap:blocks>
columnLayout can't be applied if you don't extend block base. (which is really pathetic design). Nevertheless, values range from 1-4 and "auto".
Created working plnkr here
How to build custom SAPUI control?

You can wrap the target controls up with sap.uxap.BlockBase[API]. BlockBase controls are intended to be used inside sap.uxap.ObjectPageSubSection (hence the name <blocks>) and support customizing the grid spans with the property columnLayout.
Here is a demo: https://embed.plnkr.co/lSrDk9/?show=view%2FHome.view.xml,preview
<uxap:ObjectPageSubSection>
<block:MyBlock columnLayout="4"/>
<block:MyBlock columnLayout="4"/>
</uxap:ObjectPageSubSection>

Provide a not elegant, but very fast way: Overwrite CSS
<uxap:ObjectPageSubSection class="fullWidthPanel">
/* CSS specificity */
.fullWidthPanel .sapUiRespGrid.sapUiRespGridHSpace1 > div {
width: 98.88888889%;
width: -webkit-calc(100% - 1rem);
width: calc(100% - 1rem)
}

Related

How to animate the removal of a MUI datagrid row in a react app

I am new to using MUI and I'm trying to create a simple animation which would trigger when a row is removed by the click of a row button (either fade out or even better have it compress). I currently have a workaround solution in which I grab the row through the data-id using document.querySelector and then add a class to it, but I would like to know how to do this using inline css.
After research it looks like I would have to use something like adding a keyframe (which I've seen done for individual elements) but I'm unclear how to do that for a row in a MUI data grid.
I've tried using UseGridApiRef and then using the getRowElement to add the below keyframe to that but can't get the syntax right.
I want to do this because currently I believe I am changing the DOM directly (very slow) by doing this:
let el = document.querySelector(`.MuiDataGrid-row[data-id="${id}"]`);
el.classList.add("animate-launch-case");
// Global css Page
.animate-launch-case {
opacity: 0;
transition: opacity 1s ease-in;
}
I want to be able to change the virtual DOM instead but having trouble understanding how to do it with state. Here is a Sandbox of my datagrid and here is an example of a keyframe I think would work:
const myEffectExit = keyframes`
0% {
opacity: 1;
transform: translateY(0);
}
100% {
opacity: 0;
transform: translateY(-200%);
}
`;

How to reload a component in SAPUI5?

I have a SAPUI5 application that uses sap.ui.core.ComponentContainer for loading other applications inside of itself. Something similar to fiori launchpad. But it is amazing that when I remove the component container from the page and try to reload it later it will be added to the HTML page but it will not shown.
var oPage = this.getView().byId("page");
oPage.removeAllContent();
if(!this._aComps[sObjectId]){
this._aComps[sObjectId] = new sap.ui.core.ComponentContainer({ name: sObjectName});
}
oPage.addContent(this._aComps[sObjectId]);
Any idea that what is the reason that it's shown only in initialization time?
While this code always works:
var oPage = this.getView().byId("page");
oPage.removeContent();
oPage.addContent(new sap.ui.core.ComponentContainer({ name: sObjectName}));
After a huge investigation it seems I found a bug in SAPUI5.
What happened after removing a ComponentContainer and add it again is that SAPUI5 removes the style="height: 100%;" from the component container element.
It seems it doesn't return back the height to its default value after adding it again. Also I tested the setVisible function and the problem exist there as well.
So what we have to do is:
var oPage = this.getView().byId("page");
oPage.removeAllContent();
if(!this._aComps[sObjectId]){
this._aComps[sObjectId] = new sap.ui.core.ComponentContainer({ name: sObjectName});
}
oPage.addContent(this._aComps[sObjectId]);
this._aComps[sObjectId].setHeight("100%"); // Set the height to 100% again!
Note: It removes the height: 100%; not only for the component container itself but for some other parent elements as well. Please concentrate on the picture! While this solution works for me, maybe in other use cases it is needed to set the height of some other elements!

TinyMCE: Get orignial textarea reference within initialization

Problem
Width of the <textarea> is defined by CSS class, for ex.: wMax or wDefault. In first case it is 100%, in the second, lets say 200px. By default TinyMCE converts everything to fixed width in pixels. Ofcourse I can set width:100% inside tinyMCE.init(), but that will not cover textarea's with wDefault / fixed with.
What I need
I need TinyMCE width to behave the same as original, % or px depending on it's CSS class.
If I could find a reference to the original textarea element within tinyMCE.init() procedure, then I could read CSS class from it, and set width: (textarea.hasClass('wMax') ? '100%' : null) or something like that
I am aware of the getElement() function, which gets me exactly that textarea. But where do I run it from? tinyMCE.activeEditor is null within init().
I'm currently still using TinyMCE 3, but it would be nice if you could answer this also for 4.x version, if there is any difference ofcourse...
Found the solution myself. Sharing.
Answering my own question in the title: It's not possible to refer to the textarea within init() procedure directly, because it does not run for each tinyMCE instance. It runs only once. But: TinyMCE has a customizable setup function, which does run for every instance and has all required references to solve the mentioned problem.
With the following code:
tinyMCE.init({
// ... your settings here ...
setup: function(ed){
if(ed.getElement().hasClass('wMax')){
ed.settings.width = '100%';
}
}
});
Any textarea with CSS class 'wMax' (replace with your own) will be replaced by TinyMCE instance having 100% width. All others will have a fixed width, equal to the width of the textarea at the moment of initialization. You can expand this approach with any width, like wHalf width:50% etc.
Note: .hasClass() function is a part of Mootools JS library. Replace with another if you use a different library.
I don't know if this will lead you into the right direction. I use this code to adjust the iframe height to fit the entered content. You could tweak it a bit to adjust its height and width to your needs (you will need to get the textarea by $('#' + ed.id) onInit.
Here is the function. Basically it changes the style attributes explicitly of the editor iframe
resizeIframe: function(frameid) {
var frameid = frameid ? frameid : this.editor.id+'_ifr';
var currentfr=document.getElementById(frameid);
if (currentfr && !window.opera){
currentfr.style.display="block";
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) { //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight + 26;
}
else if (currentfr.Document && currentfr.Document.body.scrollHeight) { //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
}
styles = currentfr.getAttribute('style').split(';');
for (var i=0; i<styles.length; i++) {
if ( styles[i].search('height:') ==1 ){
styles.splice(i,1);
break;
}
};
currentfr.setAttribute('style', styles.join(';'));
}
},

Has anyone used MT.D MultilineEntryElement?

I'm using the most recent one created by Alxandr (Feb/2012).
I'm trying to add it to a section using the same technique as I would adding an EntryElement. The MultilineEntryElement adds to the section but the receiving cell will not expand past it's default size. The MLEE will then overwrite the section below. I would like it to default to full screen width and 10 lines long. What is the best way to do this?
Thanks you!
Matt
To deal with this problem, set the RootElement's UnevenRows property to true, like this:
var r = new RootElement ("foo") { ... }
r.UnevenRows = true;
I did a bit more research on this issue. Please note - I am using my own implementation of MultilineEntryElement which is probably a bit different than others'.
First, it's worth stating that the issue does not manifest for me in "simple" scenarios - where a MultilineEntryElement is placed inside a section which is created as part of the initial creation of the RootElement. The issue only manifests when I manipulate an existing RootElement that has already been rendered by the DialogViewController.
It appears that there is a bug in the way MonoTouch.Dialog computes sizing of rows. If an element implements IElementSizing, then MT.D will call its GetHeight() overload. Once MT.D has detected an element with "irregular" height, it appears to need to call this method every time it processes a change to the enclosing section. This can be expensive... So if MT.D lays out a RootElement and hasn't found an element that implements IElementSizing, it appears that (perhaps intended as an optimization?) MT.D will IGNORE IElementSizing information for any elements that are added POST initial rendering. So the CELL's RowHeight property will return a standard row height, and the MultilineEntryElement will render a UITextView that spills over the cells below it.
The workaround I've come up with is to create a simple element called DummyElement which implements IElementSizing and returns 0 for GetHeight(), and to add it to the initial RootElement before the initial layout happens. If you do that, MT.D will register that there's an element which has an irregular height, and call the GetHeight() method on your MultilineEntryElement when you later add it to your element "DOM".
Here is my minimal impl of DummyElement in case it helps:
public class DummyElement : Element, IElementSizing
{
public DummyElement() : base ("empty")
{
}
public float GetHeight (UITableView tableView, NSIndexPath indexPath)
{
return 0;
}
}

TabLayoutPanel align tab to the right

I am using a TabLayoutPanel in GWT and I want to have the last tab show up on the right side of the page. Is it possible to do this?
Common idea:
set tab container width to "auto" instead of predefined "16384px"
set "float: right" css property to last tab
move last tab to firts position
public void onModuleLoad() {
.....
// init TabLayoutPanel
.....
Widget rightTab = tabPanel.getTabWidget(0).getParent();
DOM.setStyleAttribute(rightTab.getElement(), "float", "right");
Widget tabBar = rightTab.getParent();
tabBar.setWidth("auto");
tabPanel.selectTab(1);
}
If you want to align all tabs to right try this:
.gwt-TabBar .gwt-TabBarFirst {
width: 100%;
}
.gwt-TabBar .gwt-TabBarRest {
width: 4px;
}
.gwt-TabBar .gwt-TabBarFirst-wrapper {
width: 100%;
}
Short Answer - NO.
I drilled down to the source at GWT 2.3 and AFAIK it easier to build your own composite from TabBar and StackLayoutPanel than start fighting this implementation.
Just to save you an effort it cannot be centered easily too.
I am sorry it is like this.
it all hardcoded...
private static final int BIG_ENOUGH_TO_NOT_WRAP = 16384;
private final FlowPanel tabBar = new FlowPanel();
...
tabBar.getElement().getStyle().setWidth(BIG_ENOUGH_TO_NOT_WRAP, Unit.PX);
Why not pure CSS solution ? It is good practice to separate your code from design.
.gwt-TabLayoutPanelTabs {
width: auto!important;
}
.gwt-TabLayoutPanelTab {
float: right;
}
Remember that your tabs will come in reverse order (first added will be first on the right)
It is possible and will be very easy if you create your own tab.Just create an png image of tab shape (which is having rounded corner at top).Write one css rule.Take one FlextTable and apply that css to each cell that will be your tabs and then add that FlexTable into another mainTable. So in your mainTable in first row there will be tabFlexTable and in second row whatever you want to display after selecting particular tab.So for the first row apply horizontal alignment to right. This the way and same way I am also using in my professional projects.