I'm looking for help with refactoring my code. I wrote this:
button.btn.btn-primary ng-click="ok()" ng-show="!params.page_name && !image_thumb" ng-disabled="(!params.project_name || !logo_thumb)" Ok, create
button.btn.btn-primary ng-click="ok()" ng-show="params.page_name || image_thumb" ng-disabled="(!params.page_name || !image_thumb)" Ok, create
First condition is:
(!params.project_name || !logo_thumb)
Second condition is
(!params.page_name || !image_thumb) if params.page_name || !image_thumb
but I would like use only one button with ng-disabled. Do you have any idea what I can do?
You can combine ANDs && and ORs || with parans to get a combination of the things you want.
button.btn.btn-primary ng-click="ok()" ng-show="(!params.page_name && !image_thumb) || params.page_name || image_thumb" ng-disabled="((!params.page_name && !image_thumb) && (!params.project_name || !logo_thumb)) || ((params.page_name || image_thumb) && (!params.page_name || !image_thumb))" Ok, create
Related
I am this case conditional expression as a derived column, the result i not as expected
(DT_STR,255,1252)((Step1_Emc_stg_Heading >= "315" && Step1_Emc_stg_Heading <= "45") ? "Northbound"
: (Step1_Emc_stg_Heading >= "46" && Step1_Emc_stg_Heading <= "135") ? "Eastbound"
: (Step1_Emc_stg_Heading >= "136" && Step1_Emc_stg_Heading <= "225") ? "Southbound"
: (Step1_Emc_stg_Heading >= "226" && Step1_Emc_stg_Heading <= "314") ? "Westbound" : "Nobound")
I think that the problem is in the first case
Step1_Emc_stg_Heading >= "315" && Step1_Emc_stg_Heading <= "45"
you have to replace 45 with a number bigger than 315 or you have to use logical OR || instead or logical And &&
Step1_Emc_stg_Heading >= "315" || Step1_Emc_stg_Heading <= "45"
Update 1
Try the following expression (use numbers instead of string, and reorder conditions):
(DT_STR,255,1252)((DT_I4)Step1_Emc_stg_Heading <= 45 ? "Northbound"
: (DT_I4)Step1_Emc_stg_Heading <= 135 ? "Eastbound"
: (DT_I4)Step1_Emc_stg_Heading <= 225 ? "Southbound"
: (DT_I4)Step1_Emc_stg_Heading <= 314 ? "Westbound"
: (DT_I4)Step1_Emc_stg_Heading >= 315 ? "Northbound" : "Nobound")
I have the following condition in my angular application
else if (((column.field === "ttUser" 1|| column.field === "ttAdmin") 2&& $scope.EngttAccess) 3|| ((column.field === "btUser" 4|| column.field === "btAdmin") 5&& $scope.EngbtAccess)) {
how can i make this to solve sonar qube issue?
This should behave same way as your example.
else if (
(["ttUser", "ttAdmin"].includes(column.field) && $scope.EngttAccess) ||
(["btUser", "btAdmin"].includes(column.field) && $scope.EngbtAccess)) {
What's a smarter way of doing this? Code works fine but is klunky.
function removeEmptyPending(){
for(var row=2;row<=lastRow;row++){
if( (tkhContact.getRange('A'+row+':A'+row).getValue() == "") &&
(tkhContact.getRange('C'+row+':C'+row).getValue() == "") &&
(tkhContact.getRange('D'+row+':D'+row).getValue() == "") &&
(tkhContact.getRange('E'+row+':E'+row).getValue() == "") &&
(tkhContact.getRange('F'+row+':F'+row).getValue() == "") &&
(tkhContact.getRange('G'+row+':G'+row).getValue() == "") &&
(tkhContact.getRange('H'+row+':H'+row).getValue() == "") &&
(tkhContact.getRange('I'+row+':I'+row).getValue() == "") &&
(tkhContact.getRange('J'+row+':J'+row).getValue() == "") &&
(tkhContact.getRange('K'+row+':K'+row).getValue() == "") &&
(tkhContact.getRange('L'+row+':L'+row).getValue() == "") &&
(tkhContact.getRange('M'+row+':M'+row).getValue() == "") &&
(tkhContact.getRange('N'+row+':N'+row).getValue() == "") &&
(tkhContact.getRange('O'+row+':O'+row).getValue() == "") &&
(tkhContact.getRange('P'+row+':P'+row).getValue() == "") &&
(tkhContact.getRange('Q'+row+':Q'+row).getValue() == "") )
{
tkhContact.deleteRow(row); // tkhContact.getRange('R'+row+':R'+row).setValue("");
}
}
}
I need to skip column B since there is a formula there so it's never really blank.
Use #is_Blank()
function removeEmptyPending(){
for(var row=lastRow;row>=2;row--){
if( (tkhContact.getRange('A'+row+':A'+row).isBlank()) &&
(tkhContact.getRange('C'+row+':Q'+row).isBlank()) &&
){
tkhContact.deleteRow(row); //tkhContact.getRange('R'+row+':R'+row).setValue("");
}
}
}
This code gets all the data from row 2 to the last row, including columns A through Q. And then goes through the data. So, it gets all the data in one operation. The rows need to be deleted individually, and they must be deleted from the bottom up. That means that the outer "for" loop must decrement the counter. If you start deleting from the top down, then the row numbers from the last row deleted, change their row number.
function removeEmptyPending() {
var data,i,j,L,L2,lastRow,row,thisRow,thisValue;
data = tkhContact.getRange(2,1,lastRow-1,17).getValues();//Get all the data from row 2 to the last row
//including column A to column Q
L = data.length;//The number of inner arrays in the outer array
for (i=L;i>0,i--){//Loop through all the rows from last to row 2
thisRow = data[i];//Get one inner array which is one row of data
L2 = thisRow.length;
for (j=0;j<L2,j++){//Loop through each element of the inner array which is the column value
if (j === 1) {continue;} //Skip the second element which is column B
thisValue = thisRow[j];//The value for this column
if (thisValue) {continue;}//The value for this cell is not undefined null or empty string so continue
tkhContact.deleteRow(i+2); // tkhContact.getRange('R'+row+':R'+row).setValue("");
}
}
}
I am writing a condition in an AEM/CQ in jsp where:
ng-disabled="${!properties.enableSignInButton} || ${!(!loginForm.logInCOFInput.$invalid)} || ${(captchaShow && !captchaValidated)}"
which doesn't seems to be working.
When I print this in jsp, I get:
|||| in the page where '||' is printed literally without resolving it. Seems that is what is happening inside the ng-disabled.
two conditon must true means use "&&"
ng-disabled = "condition1 && condition2"
Any one condition true means use "||"
ng-disabled = "condition1 || condition2"
ng-disabled receives an expression there is no need to use
ng-disabled="!properties.enableSignInButton || !(!loginForm.logInCOFInput.$invalid) || (captchaShow && !captchaValidated)"
I get below error on the code:
ng-class='{removeActiveStyle:!(item.one || item.day || item.time)
,showToolTip:!(item.one || item.day || item.time)}'
Error stack
Error: [$parse:syntax] Syntax Error: Token ',' is an unexpected token at column 84 of the expression
Here you have the exact same condition. You can write it like this :
ng-class="{'removeActiveStyle showToolTip': !(item.one || item.day || item.time)}"
Working Fiddle
You need to enclose class name between single quotes,Plus you should also go through ngClass documentation https://docs.angularjs.org/api/ng/directive/ngClass
ng-class="{'removeActiveStyle':!(item.one || item.day || item.time)
,'showToolTip':!(item.one || item.day || item.time)}"
The others beat me too it!
But they are all right, you require quotes around your classes.
<div ng-class="{
'condition1': (item.one && item.two && !item.three),
'condition2': !(item.one || item.two || item.three),
'condition3': (item.one || item.two || item.three)
}">
This is a test div
</div>
Heres a working fiddle with 3 conditions and some applications of the styles
Fiddle