How to change button color in smartclient? - smartclient

I have searched for this and found this topic but it does not have enought details:
https://forums.smartclient.com/forum/smart-gwt-technical-q-a/18078-can-not-change-button-background-color
So i think you need to create your own style, or modify the existing
ones
How to create new style? How to add it? How to find existing ones? There are many css and some pcss files in my project but I do not get which ones are used by smartclient.
I am adding buttons this way:
<VLayout>
<HTMLFlow contents={`<span style="font-weight: bold">Actions</span><br>`}/>
<HTMLFlow contents={`<style></style>`}/>
<LayoutSpacer/>
{this.addNewButton = <Button title={translation.button.addNew}/>}
<LayoutSpacer/>
{this.deleteButton = <Button title={translation.button.remove} visibility={'hidden'}/>}
</VLayout>
By PhpStorm autocompletion I find there is backgroundColor property:
{this.deleteButton = <Button title={translation.button.remove} visibility={'hidden'} backgroundColor={red}/>}
But setting red this way does not work.
I have provided one answer, but it just changes background color. Need to know how to set not only background but text color, border color. Might be that I need baseStyle property but I do not see examples how to use it.
Update
I have another example where my provided answer does not work.
this._buttonSearch = <Button title={translation.button.search} width={70} autoFit baseStyle={"btn-secondary button"}/>;
this._buttonReset = <Button title={translation.button.reset} width={70} autoFit baseStyle={"btn-secondary button"}/>;
this._monthlyViewButton = <Button title={translation.button.monthly_view} width={80} autoFit baseStyle={"btn-secondary button view-btn"}/>;
// this._monthlyViewButton2 = <Button title={'montly 2'} width={80} autoFit baseStyle={"btn-secondary button view-btn"}/>;
this._weeklyViewButton = <Button title={translation.button.weekly_view} width={80} autoFit baseStyle={"btn-secondary button view-btn"}/>;
this._dailyViewButton = <Button title={translation.button.daily_view} width={80} autoFit baseStyle={"btn-secondary button active-view-btn"}/>;
this._previousDayButton = <Button title={translation.button.previous_day} width={102} autoFit baseStyle={"btn-secondary button"}/>;
this._nextDayButton = <Button title={translation.button.next_day} width={77} autoFit baseStyle={"btn-secondary button"}/>;
this._skipCheckButton = <Button title={translation.button.skip_check} width={77} autoFit baseStyle={"btn-secondary button view-btn"} backgroundColor={'white'}/>;
this._showHideUnassigned = <Button title={translation.button.hide_unassigned} prompt={translation.button.hide_unassigned} width={120} autoFit baseStyle={"btn-secondary button"}/>;
this._shiftViewButton = <Button title={translation.button.shift_view} width={80} autoFit baseStyle={"btn-secondary button view-btn"}/>;
this._dynamicForm =
<DynamicForm dataSource={page.schedules.ds.EmployeesDataSource.sc()}
useAllDataSourceFields={false}
numCols={12}
colWidths={["12%", "13%", "1%", "12%", "1%", "38%", "1%", "1%", "1%", "19%", "1%", "1%"]}>
<FormFieldItem name={"text"} showTitle={false} showHintInField={true} hint={translation.schedules.text}/>
<FormFieldItem name={"departments"} editorType={"ComboBoxItem"} showTitle={false} showHintInField={true} hint={translation.schedules.department}/>
<FormFieldItem name={"from"} title={translation.title.day} type={"date"} width={130} useTextField={true}/>
<FormFieldItem name="" editorType="CanvasItem" createCanvas={() => this._buttonSearch} showTitle={false}/>
<FormFieldItem name="" editorType="CanvasItem" createCanvas={() => this._buttonReset} showTitle={false}/>
<FormFieldItem name="" editorType="CanvasItem" createCanvas={() => this._dailyViewButton} showTitle={false}/>
<FormFieldItem name="" editorType="CanvasItem" createCanvas={() => this._weeklyViewButton} showTitle={false}/>
<FormFieldItem name="" editorType="CanvasItem" createCanvas={() => this._skipCheckButton} showTitle={false}/>
<FormFieldItem name="" editorType="CanvasItem" createCanvas={() => this._monthlyViewButton} showTitle={false}/
<FormFieldItem name="" editorType="CanvasItem" createCanvas={() => this._shiftViewButton} showTitle={false}/>
<FormFieldItem name="previousDayButton" editorType="CanvasItem" createCanvas={() => this._previousDayButton} showTitle={false}/>
<FormFieldItem name="nextDayButton" editorType="CanvasItem" createCanvas={() => this._nextDayButton} showTitle={false}/>
</DynamicForm>;
So there is _skipCheckButton. It should be white as _weeklyViewButton - code looks same. But for some reason it is blue. What can be causing it to be blue?

While writing question and testing, I noticed that on the error I could click PhpStorm suggestion, and it created private variable red.
Then I set 'red' string to the red. And used this.red to backgroundColor property and it worked.
And then tried this way and it worked - needed to put in quotes:
{this.deleteButton = <Button title={translation.button.remove} visibility={'hidden'} backgroundColor={'red'}/>}
And about the updated part where shows blue button instead of white - the answer is - check if you are testing the right place. In my case - when clicking "Monthly" button it has probably to show blue skip check because I added just random button earlier for testing. But when clicking "Daily" button, then it had to show white button. I was testing wrong place.

Related

Special="save" button doesn't work in odoo16 form view

When I add my "save" button and "discard" button as following:
<footer>
<button string="Save" special="save" class="btn-primary" close="1" />
<button string="Discard" class="btn-secondary" special="cancel"/>
</footer>
Both buttons dont work and when I click them, nothing happends.

Focus on TextField React

I have a problem trying to get the data from text inputs.
The problem occurs when I try to fill an input, everytime I enter a character the cursor stop being in the input field and I need to click again in the field to continue writing. It's like if when I enter a letter the focus on the input dissapear.
I tried to put an 'autofocus' on the textfield, works but the cursor goes to the next text field.
I'm using material ui
<Typography id="modal-modal-title" variant="h6" component="h2">
password
</Typography>
<TextField
fullWidth
type="text"
placeholder="password"
sx={{ mt: 3 }}
required
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
<Typography id="modal-modal-title" variant="h6" component="h2" sx={{ mt: 3 }}>
recover password
</Typography>
<TextField
fullWidth
type="text"
placeholder="recover contraseƱa"
sx={{ mt: 3 }}
required
value={rPassword}
onChange={(e) => setRPassword(e.target.value)}
/>

SAPUI5 - Responsive sap.m.Table

I created a sap.m.table with its header headerToolbar.
In the header, I put the title and two SelectList separated by a ToolbarSpacer.
The problem is that when the screen size is small the elements on the headerToolbar don't go back to the next line and are truncated ...
On a large screen:
On a small screen:
I want the header to be responsive, that is the elements should go to the next line if there is no sufficient space.
Here is the code:
<headerToolbar height="auto">
<Toolbar height="auto">
<content>
<Title id="tableHeader" text="..."/>
<ToolbarSpacer />
<Label text="..." lableFor="sl1"/>
<SelectList id="sl1"
enabled="true">
<core:Item key="..." text="..." />
<core:Item key="..." text="..." />
</SelectList>
<ToolbarSpacer />
<Label text="..." lableFor="sl2"/>
<SelectList id="sl2"
enabled="true">
<core:Item key="..." text="..." />
<core:Item key="..." text="..." />
</SelectList>
<ToolbarSpacer />
</content>
</Toolbar>
</headerToolbar>
Why you don't use OverflowToolbar instead of Toolbar?
Is the official responsive Toolbar
https://sapui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.OverflowToolbarFooter/preview
If you don't like it and want this "pop-in" behaviour you have described, I guess you can put a FlexBox inside your Toolbar and set the direction property depending on the "device" model.
Using expression binding will be something like this:
new sap.m.FlexBox({
direction: "{= ${device>/isPhone} ? 'Column' : 'Row' }",
items: [
//Your content goes here
]
})
More here: https://sapui5.hana.ondemand.com/#docs/guide/69a8e469fbde46e7b8916250080effbd.html
You can enable horizontal table scrolling in the css:
.enableTableScrolling {
overflow-x: scroll;
}
After that table will not be truncated.

System should not refresh after clicking on already selected radio button

I have 2 radio buttons , i selected one to them , there is an ajax call when i select that , what i want that there should not be any ajax call when i click on the already selected radio button . How to implement this.
<label for="cooperativeAuthorisedRepresentativeType">#{msg['com.crimsonlogic.egov.rol.rnra.landsubdivision.applicantdetails.cooperative.cooperativeAuthorisedRepresentativeType']}</label>
<h:selectOneRadio id="applicantDetails_cooperative_cooperativeAuthorisedRepresentativeType" required="true"
value="#{landSubdivisionController.cooperativeDetails.repCode}" requiredMessage="#{cmn['rol.common.message.error.RADIO_REQUIRED']}" >
<f:selectItem itemLabel="#{msg['REPRWAND']}" itemValue="REPRWAND" />
<f:selectItem itemLabel="#{msg['REPFOR']}" itemValue="REPFOR" />
<f:validateRequired />
<a4j:ajax event="click" listener="#{landSubdivisionController.changeRepresentativeTypeForCooperative()}" render="cooperativeCitizenNationalId,cooperativeCitizenNationalIdForFranchisee,cooperativeCitizenSurname,cooperativeCitizenOtherNames,cooperativeCitizenDistrict,cooperativeCitizenSector,cooperativeCitizenCell,cooperativeCitizenVillage,cooperativeForeignerPassportNo,cooperativeForeignerSurname,cooperativeForeignerOtherNames,cooperativeForeignerCountry,cooperativeForeignerCity" />
</h:selectOneRadio>
<div class="col-md-4">
<h:message for="applicantDetails_cooperative_cooperativeAuthorisedRepresentativeType" styleClass="help-block"></h:message>
</div>
You should use change event instead of click event of javascript.
You can try writing like this:
<a4j:ajax event="change"

In Titanium JS, when setting rightNavButtons, the buttons only work for the first 4 taps

In my app for iOS I've used the rightNavButtons property of a window to add two buttons in the top right.
However, the click events on these buttons only work for the first 4 taps and then nothing happens when you click on them. What is going on? Could this be a bug with Titanium?
Here is my code:
Titanium SDK version: 3.4.0.v20140916181713
Alloy version: 1.5.1
Controller - index.js:
var addButton = Ti.UI.createButton({ systemButton: Ti.UI.iPhone.SystemButton.ADD });
var searchButton = Ti.UI.createButton({ systemButton: Ti.UI.iPhone.SystemButton.SEARCH });
addButton.addEventListener("click", function () {
console.log("ADD was clicked!");
});
searchButton.addEventListener("click", function () {
console.log("SEARCH was clicked!");
});
$.win.setRightNavButtons([searchButton, addButton]);
$.index.open();
View - index.xml
<Alloy>
<TabGroup>
<Tab title="Tab 1" icon="KS_nav_ui.png">
<Window id="win" title="Tab 1">
<Label>I am Window 1</Label>
</Window>
</Tab>
<Tab title="Tab 2" icon="KS_nav_views.png">
<Window title="Tab 2">
<Label>I am Window 2</Label>
</Window>
</Tab>
</TabGroup>
</Alloy>
Found a workaround!
I avoid the <RightNavButtons>, which can contain more than one view.
Instead I use <RightNavButton> which can contain only one child view.
To add still add two buttons to my navbar, I nested the buttons in the view container (the single child of the <RightNavButton>.
<RightNavButton>
<View>
<Button class="i i-heart nav-button" id="favorite" onClick="toggleFavorite" right="0" />
<Button class="i i-share nav-button" id="share" right="32" />
</View>
</RightNavButton>
No issues anymore. Both onClick events of the <Button> childs inside the View container are fired.
Tested this code and it should work for you
<Tab title="Tab 1" icon="KS_nav_ui.png">
<Window id="win" title="Tab 1">
<RightNavButtons platform=ios>
<Button systemButton="Ti.UI.iPhone.SystemButton.ADD" onClick="addHandler" />
<Button systemButton="Ti.UI.iPhone.SystemButton.SEARCH" onClick="searchHandler" />
</RightNavButtons>
<Label>I am Window 1</Label>
</Window>
</Tab>
When I tried to execute your code, the event listeners weren't being called at all for me on 3.4.0.GA / Alloy 1.5.0 and iOS8 Simulator.
However, when I put the RightNavButton inside the XML as below, it worked fine and the event listener was called every time I clicked on it. Looks like a bug to me...
<Tab title="Tab 1" icon="KS_nav_ui.png">
<Window id="win" title="Tab 1">
<RightNavButton platform=ios>
<Button systemButton="Ti.UI.iPhone.SystemButton.ADD" onClick="closeWindow" />
</RightNavButton>
<Label>I am Window 1</Label>
</Window>
</Tab>