@kaspernj/api-maker 1.0.427 → 1.0.429
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -83,7 +83,15 @@ export default memo(shapeComponent(class ApiMakerSuperAdminShowPage extends Base
|
|
|
83
83
|
if (nameAttribute && !select[reflectionModelClassName].includes("name")) select[reflectionModelClassName].push("name")
|
|
84
84
|
|
|
85
85
|
// The foreign key is needed to look up any belongs-to-relationships
|
|
86
|
-
if (!modelClassSelect.includes(reflection.foreignKey()))
|
|
86
|
+
if (!modelClassSelect.includes(reflection.foreignKey())) {
|
|
87
|
+
const foreignKeyAttribute = reflectionModelClassAttributes.find((attribute) => attribute.name() == reflection.foreignKey())
|
|
88
|
+
|
|
89
|
+
if (!foreignKeyAttribute) {
|
|
90
|
+
throw new Error(`${reflection.foreignKey()} wasn't defined as an attribute on ${modelClassName}`)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
modelClassSelect.push(reflection.foreignKey())
|
|
94
|
+
}
|
|
87
95
|
} else if (reflection.macro() == "has_one") {
|
|
88
96
|
const reflectionModelClass = reflection.modelClass()
|
|
89
97
|
const reflectionModelClassName = reflectionModelClass.modelClassData().name
|
|
@@ -4,10 +4,13 @@ import Checkbox from "../../bootstrap/checkbox"
|
|
|
4
4
|
import {digg} from "diggerize"
|
|
5
5
|
import {Form} from "../../form"
|
|
6
6
|
import Input from "../../bootstrap/input"
|
|
7
|
+
import modelClassRequire from "../../model-class-require.mjs"
|
|
7
8
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
8
9
|
import {memo} from "react"
|
|
9
10
|
import useI18n from "i18n-on-steroids/src/use-i18n.mjs"
|
|
10
11
|
|
|
12
|
+
const TableSearch = modelClassRequire("TableSearch")
|
|
13
|
+
|
|
11
14
|
export default memo(shapeComponent(class ApiMakerTableFiltersSaveSearchModal extends BaseComponent {
|
|
12
15
|
setup() {
|
|
13
16
|
const {t} = useI18n({namespace: "js.api_maker.table.filters.save_search_modal"})
|
|
@@ -46,16 +49,21 @@ export default memo(shapeComponent(class ApiMakerTableFiltersSaveSearchModal ext
|
|
|
46
49
|
onSaveSearchSubmit = async () => {
|
|
47
50
|
const formData = this.s.form.asObject()
|
|
48
51
|
const {currentFilters, currentUser, onRequestClose, search} = this.p
|
|
52
|
+
const hasUserTypeColumn = Boolean(TableSearch.attributes().find((attribute) => attribute.name() == "user_type"))
|
|
49
53
|
|
|
50
54
|
if (search.isNewRecord()) {
|
|
51
55
|
formData.table_search.query_params = JSON.stringify(currentFilters())
|
|
52
56
|
}
|
|
53
57
|
|
|
54
|
-
|
|
58
|
+
if (hasUserTypeColumn) {
|
|
59
|
+
formData.table_search.user_type = digg(currentUser.modelClassData(), "className")
|
|
60
|
+
}
|
|
61
|
+
|
|
55
62
|
formData.table_search.user_id = currentUser.id()
|
|
56
63
|
|
|
57
64
|
try {
|
|
58
65
|
await search.saveRaw(formData)
|
|
66
|
+
FlashMessage.success(this.t(".", {defaultValue: "The search was saved."}))
|
|
59
67
|
onRequestClose()
|
|
60
68
|
} catch (error) {
|
|
61
69
|
FlashMessage.errorResponse(error)
|