Skip to content

Commit

Permalink
Merge pull request #11 from 40ants/feat/overridable-default-event
Browse files Browse the repository at this point in the history
Feat/overridable default event
  • Loading branch information
svetlyak40wt authored Jul 29, 2024
2 parents b35f364 + 01dd145 commit 204418d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 113 deletions.
72 changes: 10 additions & 62 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,15 @@
"steps": [
{
"name": "Checkout Code",
"uses": "actions/checkout@v3"
},
{
"name": "Grant All Perms to Make Cache Restoring Possible",
"run": "sudo mkdir -p /usr/local/etc/roswell\n sudo chown \"${USER}\" /usr/local/etc/roswell\n # Here the ros binary will be restored:\n sudo chown \"${USER}\" /usr/local/bin",
"shell": "bash"
},
{
"name": "Get Current Month",
"id": "current-month",
"run": "echo \"value=$(date -u \"+%Y-%m\")\" >> $GITHUB_OUTPUT",
"shell": "bash"
},
{
"name": "Cache Roswell Setup",
"id": "cache",
"uses": "actions/cache@v3",
"with": {
"path": "qlfile\nqlfile.lock\n~/.cache/common-lisp/\n~/.roswell\n/usr/local/etc/roswell\n/usr/local/bin/ros\n/usr/local/Cellar/roswell\n.qlot",
"key": "a-${{ steps.current-month.outputs.value }}-${{ env.cache-name }}-ubuntu-latest-quicklisp-sbcl-bin-${{ hashFiles('qlfile.lock', '*.asd') }}"
}
},
{
"name": "Restore Path To Cached Files",
"run": "echo $HOME/.roswell/bin >> $GITHUB_PATH\n echo .qlot/bin >> $GITHUB_PATH",
"shell": "bash",
"if": "steps.cache.outputs.cache-hit == 'true'"
"uses": "actions/checkout@v4"
},
{
"name": "Setup Common Lisp Environment",
"uses": "40ants/setup-lisp@v3",
"uses": "40ants/setup-lisp@v4",
"with": {
"asdf-system": "reblocks-ui"
},
"if": "steps.cache.outputs.cache-hit != 'true'"
"asdf-system": "reblocks-ui",
"cache": "true"
}
},
{
"name": "Change dist to Ultralisp if qlfile does not exist",
Expand Down Expand Up @@ -92,41 +66,15 @@
"steps": [
{
"name": "Checkout Code",
"uses": "actions/checkout@v3"
},
{
"name": "Grant All Perms to Make Cache Restoring Possible",
"run": "sudo mkdir -p /usr/local/etc/roswell\n sudo chown \"${USER}\" /usr/local/etc/roswell\n # Here the ros binary will be restored:\n sudo chown \"${USER}\" /usr/local/bin",
"shell": "bash"
},
{
"name": "Get Current Month",
"id": "current-month",
"run": "echo \"value=$(date -u \"+%Y-%m\")\" >> $GITHUB_OUTPUT",
"shell": "bash"
},
{
"name": "Cache Roswell Setup",
"id": "cache",
"uses": "actions/cache@v3",
"with": {
"path": "qlfile\nqlfile.lock\n~/.cache/common-lisp/\n~/.roswell\n/usr/local/etc/roswell\n/usr/local/bin/ros\n/usr/local/Cellar/roswell\n.qlot",
"key": "a-${{ steps.current-month.outputs.value }}-${{ env.cache-name }}-ubuntu-latest-quicklisp-sbcl-bin-${{ hashFiles('qlfile.lock', '*.asd') }}"
}
},
{
"name": "Restore Path To Cached Files",
"run": "echo $HOME/.roswell/bin >> $GITHUB_PATH\n echo .qlot/bin >> $GITHUB_PATH",
"shell": "bash",
"if": "steps.cache.outputs.cache-hit == 'true'"
"uses": "actions/checkout@v4"
},
{
"name": "Setup Common Lisp Environment",
"uses": "40ants/setup-lisp@v3",
"uses": "40ants/setup-lisp@v4",
"with": {
"asdf-system": "reblocks-ui"
},
"if": "steps.cache.outputs.cache-hit != 'true'"
"asdf-system": "reblocks-ui",
"cache": "true"
}
},
{
"name": "Change dist to Ultralisp",
Expand Down
36 changes: 5 additions & 31 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,15 @@
"steps": [
{
"name": "Checkout Code",
"uses": "actions/checkout@v3"
},
{
"name": "Grant All Perms to Make Cache Restoring Possible",
"run": "sudo mkdir -p /usr/local/etc/roswell\n sudo chown \"${USER}\" /usr/local/etc/roswell\n # Here the ros binary will be restored:\n sudo chown \"${USER}\" /usr/local/bin",
"shell": "bash"
},
{
"name": "Get Current Month",
"id": "current-month",
"run": "echo \"value=$(date -u \"+%Y-%m\")\" >> $GITHUB_OUTPUT",
"shell": "bash"
},
{
"name": "Cache Roswell Setup",
"id": "cache",
"uses": "actions/cache@v3",
"with": {
"path": "qlfile\nqlfile.lock\n~/.cache/common-lisp/\n~/.roswell\n/usr/local/etc/roswell\n/usr/local/bin/ros\n/usr/local/Cellar/roswell\n.qlot",
"key": "a-${{ steps.current-month.outputs.value }}-${{ env.cache-name }}-ubuntu-latest-quicklisp-sbcl-bin-${{ hashFiles('qlfile.lock', '*.asd') }}"
}
},
{
"name": "Restore Path To Cached Files",
"run": "echo $HOME/.roswell/bin >> $GITHUB_PATH\n echo .qlot/bin >> $GITHUB_PATH",
"shell": "bash",
"if": "steps.cache.outputs.cache-hit == 'true'"
"uses": "actions/checkout@v4"
},
{
"name": "Setup Common Lisp Environment",
"uses": "40ants/setup-lisp@v3",
"uses": "40ants/setup-lisp@v4",
"with": {
"asdf-system": "reblocks-ui-docs"
},
"if": "steps.cache.outputs.cache-hit != 'true'"
"asdf-system": "reblocks-ui-docs",
"cache": "true"
}
},
{
"name": "Build Docs",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"steps": [
{
"name": "Checkout Code",
"uses": "actions/checkout@v3"
"uses": "actions/checkout@v4"
},
{
"name": "Create release tag",
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/.qlot/
.DS_Store
*.fasl
*.~undo-tree~
7 changes: 7 additions & 0 deletions docs/changelog.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
"JS"
"UI"
"40ANTS-DOC"))
(0.17.0 2024-07-28
"
Fixed
=====
- Code was fixed to work with latest changed to Reblocks, introduced in [PR 57](https://github.com/40ants/reblocks/pull/57).
")
(0.16.0 2022-12-12
"
Changed
Expand Down
6 changes: 3 additions & 3 deletions qlfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
("quicklisp" .
(:class qlot/source/dist:source-dist
:initargs (:distribution "http://beta.quicklisp.org/dist/quicklisp.txt" :%version :latest)
:initargs (:distribution "https://beta.quicklisp.org/dist/quicklisp.txt" :%version :latest)
:version "2023-10-21"))
("ultralisp" .
(:class qlot/source/dist:source-dist
:initargs (:distribution "http://dist.ultralisp.org" :%version :latest)
:version "20240303155001"))
:initargs (:distribution "https://dist.ultralisp.org" :%version :latest)
:version "20240723211501"))
30 changes: 14 additions & 16 deletions src/form.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
(:use #:cl)
(:import-from #:log)
(:import-from #:spinneret)
(:import-from #:serapeum
#:defvar-unbound
#:eval-always)
(:import-from #:reblocks/actions
#:make-action-url
#:make-action)
Expand Down Expand Up @@ -36,8 +39,12 @@
#:get-field-errors-count))
(in-package reblocks-ui/form)

(defvar *js-default-action* "return initiateAction(\"~A\")")

(serapeum:defvar-unbound *form-field-errors*
(eval-always
(defvar *js-default-form-action* "return initiateFormAction(\"~A\", event, this)"))

(defvar-unbound *form-field-errors*
"This variable will hold a hash-table where keys are field names and values
are lists of strings of error messages.")

Expand Down Expand Up @@ -174,7 +181,7 @@ $('~A').foundation();
extra-submit-code
requires-confirmation-p
(confirm-question "Are you sure?")
(submit-fn "initiateFormAction(\"~A\", $(this), \"~A\")")
(submit-fn *js-default-form-action*)
;; A hashmap with placeholders widgets
error-placeholders)
(let* ((action (if (functionp action)
Expand Down Expand Up @@ -230,16 +237,9 @@ $('~A').foundation();
action))
(action-code (make-action action))
(on-submit (when use-ajax-p
(format nil "~@[~A~]~A; return false;"
extra-submit-code
(format nil submit-fn
(url-encode (or action-code ""))
;; Function session-name-string-pair was removed
;; during reblocks refactoring, so we just
;;
""
;; (reblocks::session-name-string-pair)
))))
(concatenate 'string
(or extra-submit-code "")
(format nil submit-fn (url-encode (or action-code ""))))))
(popup-name (when requires-confirmation-p
(symbol-name
(gensym "popup"))))
Expand Down Expand Up @@ -364,7 +364,6 @@ $('~A').foundation();
(t confirm-question))
env))))


(defmacro with-html-form ((method-type
action &key
id
Expand All @@ -374,7 +373,7 @@ $('~A').foundation();
extra-submit-code
requires-confirmation-p
(confirm-question "Are you sure?")
(submit-fn "initiateFormAction(\"~A\", $(this), \"~A\")"))
(submit-fn *js-default-form-action*))
&body body
&environment env)
"Wraps a body with (:form ...) using REBLOCKS/HTML:WITH-HTML.
Expand Down Expand Up @@ -500,8 +499,7 @@ bot, crawling the internet will hit this action with GET request."
(action-code (make-action action))
(url (make-action-url action-code))
(on-click (when ajaxp
(format nil "initiateAction(\"~A\"); return false;"
action-code))))
(format nil *js-default-action* action-code))))

(with-html
(:a :id id
Expand Down

0 comments on commit 204418d

Please sign in to comment.