GSheets Multi-Select Dropdown affects entire worksheet instead of a specific sheet - google-sheets-api

I am new to this and I found an old post with this code. I am currently using it but it affects all tabs of my spreadsheet. Is there a way for it to work on a specific tab only? Thank you.
`const separator = ', ';
const dvType = SpreadsheetApp.DataValidationCriteria.VALUE_IN_RANGE;
function onEdit(e) {
if (e.value != null && e.oldValue != null && e.value !== "") {
var dataValidation = e.range.getDataValidation();
if(dataValidation != null && dataValidation.getCriteriaType() == dvType &&
e.value.indexOf(separator) < 0 && e.oldValue.indexOf(e.value) < 0) {
e.range.setValue(e.oldValue + separator + e.value);
}
}
}`
I tried to change the criteria but since I am new to coding, I always get error.

Related

tab issue in safari browser while typing username and password

when user is typing tab after enter username in box then cursor move to the password box and get back to the username input box after typing one or two letter.
I have create one method name moveToPassword() and i am facing problem that whenever i am typing single character in username it is calling onInputChange(). it is running well in other browser only getting problem with safari ... second input block (where ng-if="login.isIOS" ) is for safari
login.html
_self.onInputChange = function (inputValue) {
toggleLogin(inputValue);
};
_self.moveToPassword = function ($event) {
if ($event.keyCode === 9) {
document.getElementById("password").focus();
}
}
/**
* #description Toggle Login button as per Input conditions.
* #returns {}
*/
function toggleLogin(inputValue) {
if (inputValue || inputValue === '') {
_self.loginInputs.userName = inputValue;
}
_self.dropdownStatus = false;
if (_self.loginInputs.userName !== undefined &&
_self.loginInputs.userName.length !== 0 &&
_self.loginInputs.password.length !== 0 &&
!(basAuthService.authentication.isAuth && !basAuthService.authentication.isConfigReady)) {
_self.loginButtonStatus = false;
} else {
_self.loginButtonStatus = true;
}
//For disable domain dropdown as per user conditions
if (_self.loginInputs.userName.indexOf('#') > 0 || _self.loginInputs.userName.indexOf('\\') > 0) {
_self.loginInputs.domain = '';
_self.dropdownStatus = true;
}
}`
`

Is there a function for checkbox hide/show row in appscript google spreadsheet?

I currently have I55:I231 as my tickbox option to hide and show the row, and the range is from A55:H231, some formula is not working for me, Is this possible to run a code?
Thank you for your help!
function onEdit(e) {
const col = e.range.columnStart;
if (col !== 9) { return; }
const row = e.range.rowStart;
if (row < 55 || row > 231) { return; }
console.log(e.value);
if (e.value === 'TRUE') { e.source.getActiveSheet().hideRows(row); }
}

vue.js function only working if value is greater than zero

I have the following function that is formating font colour based on the value returned. The value returned is from a GraphQl non-nullable field and is in a range from 0-10. It works perfectly if the value is 1-10, if the value is zero it does not run as expected.
formatFont: function (state) {
if (state) {
if (state >= 0 && state <= 6) {
return 'red--text';
} else if (state >= 7 && state <= 8) {
return 'orange--text';
} else if (state >= 9 && state <= 10) {
return 'green--text';
} else {
return 'white-text' // i.e. white on white = invisible
}
} else {
console.log('Output else')
return 'white--text' // i.e. white on white = invisible
}
}
If the value is zero it will return the else statement, I have a solution to increment each value by 1 which resolves but it feels like a hack, I want to understand why it doesn't recognise zero?
change
if (state) {
to
if (typeof state !== 'undefined') {
why because 0 is falsey
var a= 0
var b= '0'
var c= 1
if(a) {
console.info('a',a)
}
if(b){
console.info('b',b)
}
if(c){
console.info('c',c)
}
Because of the 0 as a false consider but you pass as a string then it will go the true.

Filtering by date range within a computed array?

Within my app I'm trying to develop the ability to filter my returned array of offers if they fall within a set of dates set using a datepicker.
My datepicker emits the values to two properties within a range object - this is filters.range.startDate & filters.range.endDate. Each offer in my array has the properties, offer.dates.start & offer.dates.end.
I've added the below statement in my computed property which doesn't break the computed, just returns no results regardless of dates.
Does anyone have any advice?
EDIT- Added the entire computed property with the date range statement as the last condition.
computed: {
filteredOffers() {
let filtered = this.offers.filter(offer => {
return (offer.island === this.filters.islandFilter || this.filters.islandFilter === 'All') // Island
&& (offer.starrating === this.filters.starRating || this.filters.starRating === 'All') // Star Rating
&& (offer.board === this.filters.boardBasis || this.filters.boardBasis === 'All') // Board Basis
&& (offer.duration === this.filters.duration || this.filters.duration === 'All') // Duration
&& (offer.price.from < this.filters.price) // Price
&& (this.filters.travelby === 'sea' && offer.travel.air === false || this.filters.travelby === 'All') // Sea or Air
&& (this.filters.range.startDate >= offer.dates.start && offer.dates.end <= this.filters.range.endDate) // DATE RANGE!!
});
if (this.sortby === 'ascending') {
return filtered.sort((a, b) => {
return a.price.from - b.price.from;
})
} else {
return filtered.sort((a, b) => {
return b.price.from - a.price.from;
})
}
}
}
First, I would transform your date objects to timestamp in milliseconds, just avoid some format errors when you compare.
let date = new Date();
let timestamp = date.getTime();
After that, I guess your logic is not correct, because your end date on filter should be greater than your offer end date, and your start date on filter should be smaller than your offer start date.
this.filters.range.startDate <= offer.dates.start && this.filters.range.endDate >= offer.dates.end

How to write my code in dojo

$(document).mouseup(function (e) {
var popup = $("#searchProductContainer");
var address_popup = $('#widget_deliveryLoc_Content')
if (!$('#headerSearchList').is(e.target) && !popup.is(e.target) && popup.has(e.target).length == 0 ) {
popup.hide();
}
if(!$('#widget_deliveryLoc_position').is(e.target) && !address_popup.is(e.target) && address_popup.has(e.target).length == 0){
address_popup.hide();
}
});
Open your browser console(better result in chrome) and print object e in console.log then check its structure and analyze why you are not getting your id.