Combobox - Validate not called - plugins

Can someone please give me a hint for the combobox use (LrView) in the lightroom sdk 6.0?
My validate function is not being called. I don't know why. Anybody a hint what I'm doing wrong?
Here is the code:
...
local validateComboboxValue = function (view, value)
outputToLog("in validate...")
if(value ~= "Ja" and value ~= "Nein") then
outputToLog("wrong value")
view.value = "Ja"
return false, "Ja", "Ungültige Eingabe"
else
outputToLog("valid value")
return true, value, ""
end
end
...
f:combo_box {
font = "<system>",
title = "enableSharing",
enabled = bind 'enableSharingEnabled',
items = {
"Ja",
"Nein"
},
value = bind 'sharingEnabled',
width = LrView.share "label_width",
immediate = true,
validate = validateComboboxValue,
},
...
I'm using Lightroom on a Windows 10 machine.

Related

Using dynamic Kubernetes annotations in Terraform based on a variable

I am trying to add a set of annotations based on a variable value.
So far, I am trying to add something like:
annotations = merge({
annotation1 = value
annotation2 = value
try(var.omitAnnotations == false) == null ? {} : {
annotation3 = value
annotation4 = value
}})
However, this doesn't appear to be working as expected, and in fact, the annotations are always added, regardless of the value in var.addAnnotations
How can I get this logic working, so that annotation3 & annotation4 are only added when var.addAnnotations is true?
Thanks in advance!
I would suggest moving any expressions that are too complicated to a local variable, because of visibility:
locals {
annotations = var.omitAnnotations ? {} : {
"annotation3" = "value3"
"annotation4" = "value4"
}
add_annotations = try(local.annotations, null)
}
What this will do is set the local.annotations variable to an empty map if var.omitAnnotations is true or to a map with annotations annotation3 and annotation4 defined if var.omitAnnotations is false. The local variable add_annotations will then have the value assigned based on using the try built-in function [1]. In the last step, you would just do the following:
annotations = merge(
{
"annotation1" = "value1"
"annotation2" = "value2"
},
local.add_annotations
)

SAPUI5 oData POST 500 error

I'm trying to do a oData create on checkbox pressed and getting the following errors. Not sure if this is front end or a back end ABAP issue as have got this same function working in another project.
It is failing on the create part but strangely is still passing through the details for SiteId, ArticleNumber, VarianceDate & Confirmed.
// Set CheckBox status, X for true, blank for false
onVarianceChecked: function (oEvent) {
var oEntry = {};
var bindingContext = oEvent.getSource().getBindingContext(this.MODEL_VIEW);
var path = bindingContext.getPath();
var object = bindingContext.getModel("SI").getProperty(path);
// Pass in the Header fields
oEntry.SiteId = this.SiteId;
oEntry.ArticleNumber = object.ArticleNumber;
oEntry.VarianceDate = moment(new Date(object.VarianceDate)).format('YYYY-MM-DDTHH:mm:ss');
// Set X or blank
if (oEvent.getParameter("selected") === true) {
oEntry.Confirmed = "X";
} else {
oEntry.Confirmed = "";
}
// Do the create
var oModel = this.getView().getModel("SI");
oModel.create("/VarianceHeaderSet", oEntry, {
success: function () {
console.log("Variance confirmed");
MessageToast.show("Variance confirmed", {
duration: 1000
});
},
error: function (oError) {
console.log("Error, variance could not be confirmed");
MessageToast.show("Error, variance could not be confirmed", {
duration: 1000
});
}
});
}
'000000000' is the initial value for Edm.DateTime, hence it will fail when you have modelled a DateTime property to not be nullable.
Go to SEGW and change the property to "nullable" or make sure that you always provide a correct Date in the POST.

Setting URL in UploadCollectionItem in UI5 1.38.4

What parameters are mandatory for an UploadCollectionItem with the URL parameter set will show the file when the filename is clicked.
I am using a factory to handle files coming from different locations.
attachmentFactory(sId, context) {
const modelObj = context.getModel().getProperty(context.getPath());
const uploadListItem = new SAPUploadCollectionItem();
// If __metadata exists, attachment entry is from odata, if not then it's a FileEntry object.
if (modelObj.__metadata) {
uploadListItem.setFileName(modelObj.FILE_NAME);
uploadListItem.setMimeType(modelObj.MIME_CODE);
uploadListItem.setUrl("https://upload.wikimedia.org/wikipedia/commons/4/49/Koala_climbing_tree.jpg");
}
else {
uploadListItem.setFileName(modelObj.name);
uploadListItem.setMimeType(modelObj.type);
uploadListItem.setUrl("https://upload.wikimedia.org/wikipedia/commons/4/49/Koala_climbing_tree.jpg");
}
return uploadListItem;
}
I get an exception in UI5 when I press the link in the function
UploadCollection.prototype._triggerLink = function(oEvent, oContext) {
var iLine = null;
var aId;
if (oContext.editModeItem) {
//In case there is a list item in edit mode, the edit mode has to be finished first.
sap.m.UploadCollection.prototype._handleOk(oEvent, oContext, oContext.editModeItem, true);
if (oContext.sErrorState === "Error") {
//If there is an error, the link of the list item must not be triggered.
return this;
}
oContext.sFocusId = oEvent.getParameter("id");
}
aId = oEvent.oSource.getId().split("-");
iLine = aId[aId.length - 2];
sap.m.URLHelper.redirect(oContext.aItems[iLine].getProperty("url"), true);
};
oContext.aItems is an array but the source.getId() value is "__item9-ta_filenameHL" so __item9 is not found in oContext.aItems
I'm not sure if this is a bug or I'm setting up my UploadCollectionItem incorrectly
I had to set the sId of the UploadCollectionItem to be the sId that was passed into the factory.

How to use PropertyCriteria on complex property?

I'm new to EPiSERVER. Currently trying to search for a page with a specific property set to a specific value.
I need the property CatalogEntryPoint (a ContentReference) to equal something. Here is the criterea:
PropertyCriteria secCriteria = new PropertyCriteria();
secCriteria.Condition = CompareCondition.Equal;
secCriteria.Name = "CatalogEntryPoint.ID";
secCriteria.Type = PropertyDataType.Number;
secCriteria.Value = currentContent.ContentLink.ID.ToString();
secCriteria.Required = true;
And here is an excerpt from the search index:
{
"CatalogEntryPoint": {
"$type": "EPiServer.Find.Cms.IndexableContentReference, EPiServer.Find.Cms",
"ID$$number": 1073742170,
"WorkID$$number": 0,
"ProviderName$$string": "CatalogContent",
"GetPublishedOrLatest$$bool": false,
"IsExternalProvider$$bool": true,
"___types": [
"EPiServer.Find.Cms.IndexableContentReference",
"EPiServer.Core.ContentReference",
"System.Object",
"System.IComparable",
"EPiServer.Data.Entity.IReadOnly"
]
},
It would seem that the CatalogEntryPoint.ID-notation does not work as I'm getting 0 results. How should I write it?
The PropertyDataType has a ContentReference option. The following should work:
PropertyCriteria secCriteria = new PropertyCriteria();
secCriteria.Condition = CompareCondition.Equal;
secCriteria.Name = "CatalogEntryPoint";
secCriteria.Type = PropertyDataType.ContentReference;
secCriteria.Value = currentContent.ContentLink.ToString();
secCriteria.Required = true;
You could also just do ContentLink.ID.ToString(), the code ContentLink.ToString() preserves the content version I believe.

How can I get an alert if a specific url substring is present and nothing if null

function getCode() {
if (window.location.href.indexOf("?discount=")) {
var url = (document.URL);
var id = url.substring(url.lastIndexOf('=') + 1);
window.alert(id);
return true;
} else {
return false;
}
}
Purpose: When people go to our "Service Request" page using a QR code that has a substring of ?discount=1234. I have been testing by creating an alert box with the discount code showing. Eventually I want to be able to populate that "1234" automatically into a "Discount Code:" text field on page load.
The above is a mixture of a few suggestions when I researched it.
Result: Going to example.com/serviceRequest.html?discount=1234 gives me the appropriate alert "1234", as I want... Going to example.com/serviceRequest.html gives me the alert http://example.com/serviceRequest.html, but I don't want anything to happen if "?discount=" is null.
Any suggestions?
indexOf returns -1 if the search pattern doesn't exist. In JavaScript, anything not a 0 or false or undefined is considered true.
So your line of:
if(window.location.href.indexOf("?discount=")) {
Would better search as:
if(window.location.href.indexOf("?discount=") > -1) {
Try changing your if-statement to:
if(window.location.href.indexOf("?discount=") != -1)
Look up the documentation for ".indexOf". It returns -1 for not found and >= 0 if it is found.
...indexOf("?discount=") >= 0
substring and indexOf return -1 if the text is not found, so you can test for this. E.g.
function getCode() {
if(window.location.href.indexOf("?discount=") != -1) {
var url = (document.URL);
var id = url.substring(url.lastIndexOf('=') + 1);
window.alert(id);
return true;
}
else {
return false;
}
}
You just need to test the indexOf value:
function getCode() {
if (window.location.href.indexOf("?discount=") !== -1) {
var url = (document.URL);
var id = url.substring(url.lastIndexOf('=') + 1);
window.alert(id);
return true;
}
else {
return false;
}
}
So the quick and dirty answer would be
var discount = window.location.search.split("?discount=")[1];
alert(discount);
But this doesn't take into account the occurence of other query string parameters.
You'll really want to parse all the query parameters into a hash map.
This article does a good job of showing you a native and jQuery version.
http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html