EGL: programmatically select contents of dojocurrencytextbox - dojo

Updated with new code.
I searched through this forum already but cannot find the solution to my problem (perhaps I'm using the wrong search criteria).
What I'm looking for is a way to select the contents of a DojoCurrencyTextbox via code (programmatically).
I created a testprogram, and when I click on the currencytextbox The contents is selected (via the selectonClick property). And also when I push a button I can set the focus to the currencytextbox, but I seem unable to select the contents, for the DOjoTextField it does work, but for the DojoCurrencyTextBox it doesn't.
I hope that someone can tell me how I can get this functionality working.
The testcode I use is the following:
package dmg.zz_testruben;
// RUI Widget
import com.ibm.egl.rui.widgets.GridLayout;
import com.ibm.egl.rui.widgets.GridLayoutData;
import egl.ui.rui.Event;
import dojo.widgets.DojoButton;
import dojo.widgets.DojoCurrencyTextBox;
import dojo.widgets.DojoTextField;
handler TestSelectCurrencyTextBox type RUIWidget {targetWidget = ui, onConstructionFunction = start}
ui GridLayout{ columns = 3, rows = 4, cellPadding = 4, children = [txtInput1, btnInput1, btnInput1b, txtInput2, btnInput2, btnInput2b] };
txtInput1 DojoTextField{layoutData = new GridLayoutData{row=1, column=1}, suppressChangeEvent = true, selectOnClick = true, text = "abc"};
btnInput1 DojoButton{layoutData = new GridLayoutData{row=1, column=2}, text = "select", onClick ::= btnInput1_onClick};
btnInput1b DojoButton{layoutData = new GridLayoutData{row=1, column=3}, text = "focus", onClick ::= btnInput1b_onClick};
txtInput2 DojoCurrencyTextbox{layoutData = new GridLayoutData{row=2, column=1}, suppressChangeEvent = true, selectOnClick = true, text = "1,23"};
btnInput2 DojoButton{layoutData = new GridLayoutData{row=2, column=2}, text = "select", onClick ::= btnInput2_onClick};
btnInput2b DojoButton{layoutData = new GridLayoutData{row=2, column=3}, text = "focus", onClick ::= btnInput2b_onClick};
function start()
end
private function btnInput1_onClick (e Event in)
txtInput1.children[2].children[1].select();
end
private function btnInput2_onClick (e Event in)
txtInput2.children[2].children[1].select();
end
private function btnInput1b_onClick (e Event in)
txtInput1.focus();
end
private function btnInput2b_onClick (e Event in)
txtInput2.focus();
end
end

Call select on CurrencyTextBox's focusNode:
require([
"dojo/on",
"dijit/form/CurrencyTextBox",
"dojo/domReady!"
], function(on, CurrencyTextBox) {
var ctb = new CurrencyTextBox({
value: "54.12",
constraints:{fractional:true},
currency:'USD',
invalidMessage:'Invalid amount. Cents are required.'
}).placeAt("result");
ctb.focusNode.select();
});
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.12.1/dojo/dojo.js"></script>
<div id="result"></div>

Related

LrDialogs.runOpenDialog not working inside LrExportServiceProvider

I am trying to create a Lightroom Classic Export Service Provider plugin that has a Browse... button in the sectionsForTopOfDialog to allow the user to choose a Folder related to the plugin. The open dialog is attached to the action of the viewFactory:push_button, and the dialog opens successfully, but it seems like the rest of the push button's action is never executed, as if the runOpenPanel function never returned.
How can I create a Browse button to allow the user to select a folder and get the result? (I want to store the result in the propertyTable, this part is omitted from the code.)
Complete plugin code to reproduce the issue below. (Create a folder named runOpenDialogMCVE.lrdevplugin folder, add these files, load it as a Lightroom plugin.)
-- Info.lua
return {
LrSdkVersion = 3.0,
LrSdkMinimumVersion = 1.3, -- minimum SDK version required by this plugin
LrPluginName = "RunOpenPanel MCVE",
LrToolkitIdentifier = 'com.example.lightroom.runopenpanelmcve',
LrExportServiceProvider = {
title = "LrDialogs.runOpenPanel MCVE",
file = 'ExportServiceProvider.lua',
},
VERSION = { major=0, minor=1, revision=0 },
}
-- ExportServiceProvider.lua
local LrDialogs = import 'LrDialogs'
local LrLogger = import 'LrLogger'
local LrView = import 'LrView'
local logger = LrLogger("LrDialogs.runOpenDialogMCVE")
local viewFactory = LrView.osFactory()
logger:enable("print")
local ExportServiceProvider = {}
function ExportServiceProvider.sectionsForTopOfDialog( propertyTable )
return {
{
title = "LrDialogs.runOpenDialog MCVE",
viewFactory:row {
viewFactory:push_button {
title = "Browse...",
action = function ()
logger:trace("Opening dialog...")
LrDialogs.message("Will open dialog after this.")
local result = LrDialogs.runOpenPanel( {
title = "Location",
prompt = "Choose",
canChooseDirectories = true,
canChooseFiles = false,
allowsMultipleSelection = false,
} )
-- I would expect the code below to execute, but it never does.
-- No trace is printed and none of the dialogs below are shown.
logger.trace("Closing dialog. "..tostring(result))
if result ~= nil then
logger:trace("Chosen folder: "..result[1])
LrDialogs.message("Choseen folder: "..result[1])
else
logger:trace("Cancelled")
LrDialogs.message("Cancelled")
end
end,
},
},
},
}
end
return ExportServiceProvider
I'm using Lightroom version 12.0 on MacOS.

QUploader component in Julia

I have been developing an application in Julia using Genie Framework and Stipple, and the main task of this app is to implement Sobel and Prewitt operator. The problem that I am struggling with is the uploader component. So basically I am able to upload an image, on button click the image is transformed, but then when i upload another image and try to output the transformed version of it, the output that i get is still the old image. I have been trying to find the issue and I noticed that QUploader API has some methods that could help solve this problem: reset() method, or removeUploadedFiles() method, but I do not know how to call/use these functions regarding Julia syntax. Are there any solutions available?
const FILE_PATH = "public/sample.jpg"
const FINAL_PATH = "final.jpg"
#const IMGPATH = "demo.png"
model = Model |> init
on(model.process_s3) do _
model.imageurl[] = ""
#info "Working"
img = FileIO.load(FILE_PATH)
img_gray = Gray.(img)
#info img_gray
sobel_image = convert(Array{Float64}, img_gray)
lastImage = clamp01nan.(sobel(sobel_image, sobel3_kernel_x, sobel3_kernel_y))
save(joinpath(#__DIR__, "public", FINAL_PATH), lastImage)
model.imageurl[] = "/$FINAL_PATH#$(Base.time())" * string(rand())
#info model.imageurl[]
if (model.process_s3[])
model.process_s3[] = false
end
end
function ui(model)
[
page( model,
class = "container",
title = "Card Demo",
partial = true,
[
row( # row takes a tuple of cells. Creates a `div` HTML element with a CSS class named `row`.
cell([h1("Edge Detection Project")]),
)
row(
[
cell(class="st-module", [
h2("Initial Image"),
card(
class = "q-pa-md row items-start q-gutter-md",
uploader(
label = "Upload Image",
method = "POST",
:multiple,
url = "http://localhost:8000/upload",
field__name = "img",
:finish="finished",
ref="uploader"
),
),
btn("Sobel 3x3",color="primary", #click("process_s3 = true")),
])
cell(class="st-module", [
h2("Transformed Image"),
card(
class = "q-pa-md row items-start q-gutter-md",
#quasar(:img, src=:imageurl, spinner__color="white", style="height: 300px; max-width: 350px")
imageview(src=:imageurl, spinner__color="white", style="height: 250px; max-width: 250px")
),
])
],
)
],
),
]
end
route("/") do
html(ui(model), context = #__MODULE__)
end
route("/upload", method = POST) do
if infilespayload(:img)
#info Requests.filename(filespayload(:img))
open(FILE_PATH, "w") do io
write(FILE_PATH, filespayload(:img).data)
#info File
end
else
#info "No image uploaded"
end
Genie.Renderer.redirect(:get)
end
# isrunning(:webserver) || up()
Replace:
"/$FINAL_PATH#$(Base.time())"
with
"/$(FINAL_PATH)?t=$(Base.time())"
Explanation:
# makes just an anchor link to an HTML document. This will obviously result in buffering the document as the browser might just look for different anchors (and not find them) yet has no motivation to re-download.
On the other hand adding the ? makes the request actually different every time (understood by browser as a different document). In result the cache will not be used - a new copy gets requested.

Discord .NET Value of type EmbedBuilder cannot be converted to Embed

As the title says i get "Value of type EmbedBuilder cannot be converted to Embed" error.
This is the code i'm trying right now :
If msg.Equals("gDurum") Then
Dim eb As New EmbedBuilder With {
.Title = "Sunucu Bilgisi",
.Color = New Color(255, 0, 0),
.ImageUrl = "https://cache.gametracker.com/server_info/185.198.73.27:27015/b_560_95_1.png",
.Description = "Deneme"
}
eb.Build()
Await message.Channel.SendMessageAsync("", False, eb)
OK. I found the solution. I was trying to pass the EmbedBuilder instead of Embed.
Here's my new code :
If msg.Equals("gDurum") Then
Dim eb As New EmbedBuilder With {
.Title = "Sunucu Bilgisi",
.Color = New Color(255, 0, 0),
.ImageUrl = "https://cache.gametracker.com/server_info/185.198.73.27:27015/b_560_95_1.png",
.Description = "Deneme"
}
Await message.Channel.SendMessageAsync("", False, eb.Build())
For those who are looking at the official code example might encounter type mismatch while compiling.
Make sure to build Discord.Embed into a Rich Embed which is ready to be sent.
Corrected & working code example for this:
[Command("embed")]
public async Task SendRichEmbedAsync()
{
var embed = new EmbedBuilder
{
// Embed property can be set within object initializer
Title = "Hello world!"
Description = "I am a description set by initializer."
};
// Or with methods
embed.AddField("Field title",
"Field value. I also support [hyperlink markdown](https://example.com)!")
.WithAuthor(Context.Client.CurrentUser)
.WithFooter(footer => footer.Text = "I am a footer.")
.WithColor(Color.Blue)
.WithTitle("I overwrote \"Hello world!\"")
.WithDescription("I am a description.")
.WithUrl("https://example.com")
.WithCurrentTimestamp();
await ReplyAsync(embed: embed.Build());
}

How to show the custom PDF template while clicking the button

I want to show the PDF Template in new window while clicking the button in Sales Order. I created the button in sales order process using user event script. after that i'm unable to proceed it. It is possible to show the custom PDF template in new window while clicking the sales order?
My CODE:
USER EVENT SCRIPT:
// creating button in user event script before load event in view mode
unction userEventBeforeLoad(type, form, request){
if(type == 'view'){
var internalId = nlapiGetRecordId();
if (internalId != null) {
var createPdfUrl = nlapiResolveURL('SUITELET', 'customscript_back0rdered_itm_pdf', 'customdeploy_backord_itm_pdf_dep', false);
createPdfUrl += '&id=' + internalId;
//---add a button and call suitelet on click that button and it will open a new window
var addButton = form.addButton('custpage_printpdf', 'Print PDF', "window.open('" + createPdfUrl + "');");
}
else {
nlapiLogExecution('DEBUG', 'Error', 'Internaal id of the record is null');
}
}
}
SUITELET SCRIPT:
function suitelet(request, response){
var xml = "<?xml version=\"1.0\"?>\n<!DOCTYPE pdf PUBLIC \"-//big.faceless.org//report\" \"report-1.1.dtd\">\n";
xml += "<pdf>";
xml += "<head><macrolist><macro id=\"myfooter\"><p align=\"center\"><pagenumber /></p></macro></macrolist></head>";
xml += "<body size= \"A4\" footer=\"myfooter\" footer-height=\"0.5in\">";
var record = request.getParameter('internalId');
xml +="record"; //Add values(in string format) what you want to show in pdf
xml += "</body></pdf>";
var file = nlapiXMLToPDF(xml);
response.setContentType('PDF', 'Print.pdf ', 'inline');
response.write(file.getValue());
}
thanks in advance
The way I did it recently:
User Event Adds the Button that calls a suitelet (window.open('suitelet URL'))
Suitelet Renders the custom template
You can do the rendering like this insise a Suitelet (params: request, response), the custscript_pdf_template points to an html file on the cabinet using the NetSuite Advanced HTML syntax
var template = nlapiGetContext().getSetting('SCRIPT', 'custscript_pdf_template');
var purchaseOrder = nlapiLoadRecord('purchaseorder', tranId);
var xmlTemplate = nlapiLoadFile(template);
var renderer = nlapiCreateTemplateRenderer();
var file;
xmlTemplate = xmlTemplate.getValue();
renderer.setTemplate(xmlTemplate);
renderer.addRecord('record', purchaseOrder);
xmlTemplate = renderer.renderToString();
file = nlapiXMLToPDF(xmlTemplate);
resObj = file.getValue();
response.setContentType('PDF', 'printOut.pdf', 'inline');
response.write(resObj)

convert HTML into word in .net application

Can anyone suggest how to show value stored in SQL in HTML form to word file. I am using open xml tool to generate my word from my asp.net MVC application and it works fine but now I am stuck in one point where there is a bullet points entry stored in my DB field and I have to show it in my table cell text property?
actual value stored in DB field: "<ul><li>tapan</li><li>gupta</li></ul><p> </p>"
Run run362 = new Run();
RunProperties runProperties358 = new RunProperties();
RunFonts runFonts851 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "Helvetica", HighAnsi = "Helvetica", ComplexScript = "Arial" };
FontSize fontSize833 = new FontSize() { Val = "20" };
Languages languages772 = new Languages() { EastAsia = "zh-HK" };
runProperties358.Append(runFonts851);
runProperties358.Append(fontSize833);
runProperties358.Append(languages772);
Text text299 = new Text() { Space = SpaceProcessingModeValues.Preserve };
text299.Text = **my field value**
run362.Append(runProperties358);
run362.Append(text299);
Try Html to Open XML.
Refer Here : http://html2openxml.codeplex.com/
Hope this helps!