Memento JavaScript Library: Difference between revisions

 
(23 intermediate revisions by the same user not shown)
Line 22: Line 22:


:; Result: [[#Object DefaultEntry|'''''DefaultEntry''''' object]]
:; Result: [[#Object DefaultEntry|'''''DefaultEntry''''' object]]
==== buildDefaultEntry() ====
: The buildDefaultEntry() method is designed to facilitate the customization of default field values during the '''Creating an entry''' or '''Updating an entry''' trigger events, specifically in the '''Opening an Entry Edit card''' phase. When used in the "Creating an entry" trigger event, the buildDefaultEntry() method applies default values for new, copied, or prefilled entries.
:; Result: [[#Object DefaultEntry|'''''DefaultEntry''''' object]]
: '''Properties'''
: The buildDefaultEntry() method allows you to determine the method used by the user to create an entry. Use the following properties for this purpose:
::; buildDefaultEntry().created:  Indicates a new and empty entry.
::; buildDefaultEntry().duplicated: Indicates a duplicate of an existing entry.
::; buildDefaultEntry().prefilled:  Indicates the creation of an entry based on a template.
: '''Usage'''
: The typical usage pattern involves invoking the set() method on the result of buildDefaultEntry() to specify the field name and its corresponding default value.
:: <source lang="JavaScript">
buildDefaultEntry().set("Field name", "Field value");
</source>
: If you want to set default values only when duplicating an entry, you can use the following example:
:: <source lang="JavaScript">
if (buildDefaultEntry().duplicated) {
  buildDefaultEntry().set("Description", "Duplicated Entry")
}
</source>


==== exit() ====
==== exit() ====
Line 110: Line 135:
::; name: Name of the Link to Entry field to which to add the link
::; name: Name of the Link to Entry field to which to add the link
::; entry: Entry in the field's related library to which to link
::; entry: Entry in the field's related library to which to link
===== images(name) =====
: The images(name) method is designed to facilitate easy retrieval and manipulation of images associated with a specified field in the entry.
: '''Arguments'''
::; name: Name of the Image field
: '''Return Value'''
: An array of objects, each representing an image associated with the specified field.
::; caption: Get or set the caption for the image.
::; uri: Retrieve the URI (link) of the image.


===== recalc() =====
===== recalc() =====
Line 374: Line 409:
: '''Argument'''
: '''Argument'''
::; text: Text of the notification
::; text: Text of the notification
==== dialog() ====
: Create a builder for constructing and displaying a dialog
:; Result: [[#Object Dialog|'''''Dialog''''' object]]


==== system() ====
==== system() ====
Line 389: Line 428:
==== ''System'' properties ====
==== ''System'' properties ====
:; os: Name of the operating system executing the script
:; os: Name of the operating system executing the script
<br/>
=== Object ''Dialog'' ===
The Dialog object provides a set of methods to configure and customize the appearance and behavior of the dialog.
'''Usage'''
To use the Dialog object, instantiate it using dialog() method and then chain the available methods to configure the dialog as needed. Finally, call the show() method to display the constructed dialog to the user.
<source lang="javascript">
const myDialog = dialog()
myDialog.title("Hello")
        .text("Welcome to our application.")
        .positiveButton("OK", () => { /* Handle positive button click */ })
        .show();
</source>
'''Methods'''
:; title(string): Sets the title of the dialog. Accepts a string parameter that represents the title to be displayed.
:; text(string): Sets the main text content of the dialog. Accepts a string parameter that represents the primary message or content of the dialog.
:; view(ui object): Sets a custom view for the dialog. Accepts a [[Memento_JavaScript_UI|UI object]] that represents the custom view to be displayed within the dialog.
:; positiveButton(text, function()): Configures the positive button of the dialog. Accepts two parameters: the text to be displayed on the button and the function to be executed when the button is clicked.
:; negativeButton(text, function()): Configures the negative button of the dialog. Accepts two parameters: the text to be displayed on the button and the function to be executed when the button is clicked.
:; neutralButton(text, function()): Configures the neutral button of the dialog. Accepts two parameters: the text to be displayed on the button and the function to be executed when the button is clicked.
:; autoDismiss(bool): Sets whether the dialog should automatically dismiss when a button is clicked. Accepts a boolean parameter. If autoDismiss is set to false, the dialog will only close when a button function returns true.
:; show(): Displays the configured dialog to the user.
<br/>
<br/>