@saltcorn/markup
Advanced tools
Comparing version 0.9.5-beta.7 to 0.9.5-beta.8
@@ -639,3 +639,3 @@ "use strict"; | ||
}, | ||
action({ action_link, action_name, action_label, action_url, confirm, action_style, action_size, action_icon, configuration, action_bgcol, action_bordercol, action_textcol, }) { | ||
action({ action_link, action_name, action_label, action_url, confirm, action_style, action_size, action_icon, configuration, action_bgcol, action_bordercol, action_textcol, spinner, }) { | ||
const isMobile = !isNode || form.req?.smr; | ||
@@ -646,2 +646,3 @@ let style = action_style === "btn-custom-color" | ||
const confirmStr = confirm ? `if(confirm('${"Are you sure?"}'))` : ""; | ||
const spinnerStr = spinner ? `spin_action_link(this);` : ""; | ||
if (action_name && action_name.startsWith("Login with ")) { | ||
@@ -661,3 +662,5 @@ const method_label = action_name.replace("Login with ", ""); | ||
? "" | ||
: `btn ${action_style || "btn-primary"} ${action_size || ""}`}"${style ? ` style="${style}"` : ""}>${action_icon ? `<i class="${action_icon}"></i> ` : ""}${text(action_label || form.submitLabel || action_name || "Save")}</button>`; | ||
: `btn ${action_style || "btn-primary"} ${action_size || ""}`}"${style ? ` style="${style}"` : ""}${spinner && !onclick_or_type?.startsWith?.("on") | ||
? ` onclick="spin_action_link(this)"` | ||
: ""}>${action_icon ? `<i class="${action_icon}"></i> ` : ""}${text(action_label || form.submitLabel || action_name || "Save")}</button>`; | ||
if (action_name === "Delete") { | ||
@@ -667,3 +670,3 @@ if (action_url) { | ||
if (isNode && !form.req?.smr) { | ||
return mkBtn(`onClick="${confirmStr}ajax_post('${action_url}', {success:()=>{${form.req?.xhr ? `close_saltcorn_modal();` : ""}${dest | ||
return mkBtn(`onClick="${spinnerStr}${confirmStr}ajax_post('${action_url}', {success:()=>{${form.req?.xhr ? `close_saltcorn_modal();` : ""}${dest | ||
? `window.location.href='${dest}';` | ||
@@ -675,3 +678,3 @@ : form.req?.xhr | ||
else { | ||
return mkBtn(`onClick="${confirmStr}local_post('${action_url}', {after_delete_url:'${dest || "/"}'})" type="button"`); | ||
return mkBtn(`onClick="${spinnerStr}${confirmStr}local_post('${action_url}', {after_delete_url:'${dest || "/"}'})" type="button"`); | ||
} | ||
@@ -683,6 +686,6 @@ } | ||
if (action_name === "Reset") { | ||
return mkBtn(`onClick="${confirmStr}$(this).closest('form').trigger('reset')" type="button"`); | ||
return mkBtn(`onClick="${spinnerStr}${confirmStr}$(this).closest('form').trigger('reset')" type="button"`); | ||
} | ||
if (action_name === "Cancel") { | ||
return mkBtn(`onClick="${confirmStr}cancel_form($(this).closest('form'))" type="button"`); | ||
return mkBtn(`onClick="${spinnerStr}${confirmStr}cancel_form($(this).closest('form'))" type="button"`); | ||
} | ||
@@ -701,9 +704,9 @@ if (action_name === "GoBack") { | ||
const complete = `()=>${doNav}`; | ||
return mkBtn(`onClick="${reload}saveAndContinue(this,${isMobile ? `'${form.action}', ${complete}` : complete})" type="button"`); | ||
return mkBtn(`onClick="${spinnerStr}${reload}saveAndContinue(this,${isMobile ? `'${form.action}', ${complete}` : complete})" type="button"`); | ||
} | ||
else | ||
return mkBtn(`onClick="${reload}${doNav}" type="button"`); | ||
return mkBtn(`onClick="${spinnerStr}${reload}${doNav}" type="button"`); | ||
} | ||
if (action_name === "SaveAndContinue") { | ||
return (mkBtn(`onClick="saveAndContinue(this,${isMobile ? `'${form.action}'` : undefined})" type="button"`) + | ||
return (mkBtn(`onClick="${spinnerStr}saveAndContinue(this,${isMobile ? `'${form.action}'` : undefined})" type="button"`) + | ||
script( | ||
@@ -723,5 +726,5 @@ // cant use currentScript in callback | ||
if (action_name === "UpdateMatchingRows") | ||
return mkBtn(`onClick="updateMatchingRows(this, '${form.viewname}')" type="button"`); | ||
return mkBtn(`onClick="${spinnerStr}updateMatchingRows(this, '${form.viewname}')" type="button"`); | ||
if (action_name === "SubmitWithAjax") | ||
return mkBtn(`onClick="submitWithAjax(this)" type="button"`); | ||
return mkBtn(`onClick="${spinnerStr}submitWithAjax(this)" type="button"`); | ||
if (action_link) | ||
@@ -731,3 +734,3 @@ return action_link; | ||
const submitAttr = form.xhrSubmit | ||
? 'onClick="ajaxSubmitForm(this)" type="button"' | ||
? 'onClick="${spinnerStr}ajaxSubmitForm(this)" type="button"' | ||
: 'type="submit"'; | ||
@@ -734,0 +737,0 @@ return mkBtn(submitAttr); |
@@ -9,3 +9,3 @@ import mkTable = require("./table"); | ||
link: (href: string, s: string, attributes?: any) => string; | ||
post_btn: (href: string, s: string, csrfToken: string, { btnClass, onClick, small, style, ajax, reload_on_done, reload_delay, klass, formClass, spinner, req, confirm, icon, }?: any) => string; | ||
post_btn: (href: string, s: string, csrfToken: string, { btnClass, onClick, small, style, ajax, reload_on_done, reload_delay, klass, formClass, spinner, req, confirm, icon, title, }?: any) => string; | ||
post_delete_btn: (href: string, req: any, what?: string | undefined) => string; | ||
@@ -12,0 +12,0 @@ post_dropdown_item: (href: string, s: string, req: any, confirm?: boolean | undefined, what?: string | undefined) => string; |
@@ -12,3 +12,3 @@ "use strict"; | ||
const tags = require("./tags"); | ||
const { a, text, div, button, hr, time, i, input } = tags; | ||
const { a, text, div, button, hr, time, i, input, text_attr } = tags; | ||
const layoutUtils = require("./layout_utils"); | ||
@@ -49,3 +49,3 @@ const { alert, toast } = layoutUtils; | ||
*/ | ||
const post_btn = (href, s, csrfToken, { btnClass = "btn-primary", onClick, small, style, ajax, reload_on_done, reload_delay, klass = "", formClass, spinner, req, confirm, icon, } = {}) => `<form action="${text(href)}" method="post"${formClass ? ` class="${formClass}"` : ""}> | ||
const post_btn = (href, s, csrfToken, { btnClass = "btn-primary", onClick, small, style, ajax, reload_on_done, reload_delay, klass = "", formClass, spinner, req, confirm, icon, title, } = {}) => `<form action="${text(href)}" method="post"${formClass ? ` class="${formClass}"` : ""}> | ||
${ajax ? "" : `<input type="hidden" name="_csrf" value="${csrfToken}">`} | ||
@@ -60,3 +60,3 @@ <button ${ajax ? 'type="button"' : 'type="submit"'} ${onClick | ||
? `onclick="return confirm('${req.__("Are you sure?")}')"` | ||
: ""} class="${klass} btn ${small ? "btn-sm" : ""} ${btnClass}"${style ? ` style="${style}"` : ""}>${icon && icon !== "empty" | ||
: ""} class="${klass} btn ${small ? "btn-sm" : ""} ${btnClass}"${style ? ` style="${style}"` : ""}${title ? ` title=${text_attr(title)}` : ""}>${icon && icon !== "empty" | ||
? `<i class="${icon}"></i>${s ? " " : ""}` | ||
@@ -63,0 +63,0 @@ : ""}${s}</button></form>`; |
@@ -248,2 +248,3 @@ "use strict"; | ||
target: isWeb && segment.target_blank ? "_blank" : false, | ||
title: segment.link_title, | ||
rel: segment.nofollow ? "nofollow" : false, | ||
@@ -250,0 +251,0 @@ style, |
{ | ||
"name": "@saltcorn/markup", | ||
"version": "0.9.5-beta.7", | ||
"version": "0.9.5-beta.8", | ||
"description": "Markup for Saltcorn, open-source no-code platform", | ||
@@ -38,3 +38,3 @@ "homepage": "https://saltcorn.com", | ||
"devDependencies": { | ||
"@saltcorn/types": "0.9.5-beta.7", | ||
"@saltcorn/types": "0.9.5-beta.8", | ||
"@types/escape-html": "^1.0.1", | ||
@@ -41,0 +41,0 @@ "@types/jest": "^29.5.11", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
254779
3358