@kaspernj/api-maker 1.0.231 → 1.0.232

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
@@ -16,7 +16,7 @@
16
16
  ]
17
17
  },
18
18
  "name": "@kaspernj/api-maker",
19
- "version": "1.0.231",
19
+ "version": "1.0.232",
20
20
  "type": "module",
21
21
  "description": "",
22
22
  "main": "index.js",
package/src/params.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import config from "./config.mjs"
1
2
  import formSerialize from "form-serialize"
2
3
  import Incorporator from "incorporator"
3
4
  import qs from "qs"
@@ -26,8 +27,7 @@ export default class Params {
26
27
  const params = Params.change(given)
27
28
  const newParams = qs.stringify(params)
28
29
  const newPath = `${location.pathname}?${newParams}`
29
-
30
- let appHistory = opts.appHistory || AppHistory
30
+ const appHistory = opts.appHistory || config.getHistory() || AppHistory
31
31
 
32
32
  appHistory.push(newPath)
33
33
  }
@@ -1,5 +1,6 @@
1
1
  import Attribute from "../../base-model/attribute"
2
- import {digs} from "diggerize"
2
+ import {digg, digs} from "diggerize"
3
+ import inflection from "inflection"
3
4
  import Input from "../../inputs/input"
4
5
  import PropTypes from "prop-types"
5
6
  import PropTypesExact from "prop-types-exact"
@@ -10,13 +11,13 @@ import Services from "../../services.mjs"
10
11
  import Shape from "set-state-compare/src/shape"
11
12
 
12
13
  class AttributeElement extends React.PureComponent {
13
- static propTypes = {
14
+ static propTypes = PropTypesExact({
14
15
  active: PropTypes.bool.isRequired,
15
16
  attribute: PropTypes.instanceOf(Attribute).isRequired,
16
17
  currentModelClass: PropTypes.func.isRequired,
17
18
  fikter: PropTypes.object,
18
19
  onClick: PropTypes.func.isRequired
19
- }
20
+ })
20
21
 
21
22
  render() {
22
23
  const {active, attribute, currentModelClass} = digs(this.props, "active", "attribute", "currentModelClass")
@@ -25,7 +26,13 @@ class AttributeElement extends React.PureComponent {
25
26
  if (active) style.fontWeight = "bold"
26
27
 
27
28
  return (
28
- <div onClick={digg(this, "onAttributeClicked")} style={style}>
29
+ <div
30
+ className="attribute-element"
31
+ data-attribute-name={attribute.name()}
32
+ data-model-class={currentModelClass.modelClassData().name}
33
+ onClick={digg(this, "onAttributeClicked")}
34
+ style={style}
35
+ >
29
36
  {currentModelClass.humanAttributeName(inflection.camelize(attribute.name(), true))}
30
37
  </div>
31
38
  )
@@ -39,17 +46,23 @@ class AttributeElement extends React.PureComponent {
39
46
  }
40
47
 
41
48
  class ReflectionElement extends React.PureComponent {
42
- static propTypes = {
49
+ static propTypes = PropTypesExact({
43
50
  currentModelClass: PropTypes.func.isRequired,
44
51
  onClick: PropTypes.func.isRequired,
45
52
  reflection: PropTypes.instanceOf(Reflection).isRequired
46
- }
53
+ })
47
54
 
48
55
  render() {
49
56
  const {currentModelClass, reflection} = digs(this.props, "currentModelClass", "reflection")
50
57
 
51
58
  return (
52
- <div key={reflection.name()} onClick={digg(this, "onReflectionClicked")}>
59
+ <div
60
+ className="reflection-element"
61
+ data-model-class={currentModelClass.modelClassData().name}
62
+ data-reflection-name={reflection.name()}
63
+ key={reflection.name()}
64
+ onClick={digg(this, "onReflectionClicked")}
65
+ >
53
66
  {currentModelClass.humanAttributeName(reflection.name())}
54
67
  </div>
55
68
  )
@@ -103,7 +116,7 @@ export default class ApiMakerTableFiltersRelationshipSelect extends React.PureCo
103
116
  const {attribute, predicate, predicates, value} = digs(this.shape, "attribute", "predicate", "predicates", "value")
104
117
 
105
118
  return (
106
- <div className="api-maker--table--filters--relationship-select">
119
+ <div className="api-maker--table--filters--filter-form">
107
120
  <form onSubmit={digg(this, "onSubmit")}>
108
121
  <div>
109
122
  {this.currentPathParts().map(({translation}, pathPartIndex) =>
@@ -147,6 +160,7 @@ export default class ApiMakerTableFiltersRelationshipSelect extends React.PureCo
147
160
  <div>
148
161
  {predicates &&
149
162
  <Select
163
+ className="predicate-select"
150
164
  defaultValue={predicate?.name}
151
165
  includeBlank
152
166
  onChange={digg(this, "onPredicateChanged")}
@@ -156,14 +170,14 @@ export default class ApiMakerTableFiltersRelationshipSelect extends React.PureCo
156
170
  </div>
157
171
  <div>
158
172
  {attribute && predicate &&
159
- <Input defaultValue={value} inputRef={valueInputRef} />
173
+ <Input className="value-input" defaultValue={value} inputRef={valueInputRef} />
160
174
  }
161
175
  </div>
162
176
  </div>
163
177
  <div>
164
- <Button disabled={!attribute || !predicate}>
178
+ <button className="apply-filter-button" disabled={!attribute || !predicate}>
165
179
  {I18n.t("js.api_maker.table.filters.relationship_select.apply", {defaultValue: "Apply"})}
166
- </Button>
180
+ </button>
167
181
  </div>
168
182
  </form>
169
183
  </div>
@@ -1,3 +1,4 @@
1
+ import {digg, digs} from "diggerize"
1
2
  import PropTypes from "prop-types"
2
3
  import React from "react"
3
4
  import FilterForm from "./filter-form"
@@ -50,8 +51,8 @@ class ApiMakerTableFilters extends React.PureComponent {
50
51
  const currentFilters = this.currentFilters()
51
52
 
52
53
  return (
53
- <div className="api-maker--table--filters--edit">
54
- <button onClick={digg(this, "onAddFilterClicked")}>
54
+ <div className="api-maker--table--filters">
55
+ <button className="add-new-filter-button" onClick={digg(this, "onAddFilterClicked")}>
55
56
  {I18n.t("js.api_maker.table.filters.add_new_filter", {defaultValue: "Add new filter"})}
56
57
  </button>
57
58
  {filter &&
@@ -273,13 +273,7 @@ class ApiMakerTable extends React.PureComponent {
273
273
  } = this.props
274
274
  const {models, qParams, query, result} = digs(this.shape, "models", "qParams", "query", "result")
275
275
 
276
- let controlsContent, headerContent, PaginationComponent
277
-
278
- if (controls) {
279
- controlsContent = controls({models, qParams, query, result})
280
- }
281
-
282
- controlsContent += this.tableControls()
276
+ let headerContent, PaginationComponent
283
277
 
284
278
  if (typeof header == "function") {
285
279
  headerContent = header({models, qParams, query, result})
@@ -359,14 +353,14 @@ class ApiMakerTable extends React.PureComponent {
359
353
  return (
360
354
  <>
361
355
  {controls && controls({models, qParams, query, result})}
362
- <a href="#" onClick={digg(this, "onNewFilterClick")}>
363
- <i className="fa fa-fw fa-magnifying-glass" />
356
+ <a className="filter-button" href="#" onClick={digg(this, "onFilterClicked")}>
357
+ <i className="fa fa-fw fa-magnifying-glass la la-fw la-search" />
364
358
  </a>
365
359
  </>
366
360
  )
367
361
  }
368
362
 
369
- onNewFilterClick = (e) => {
363
+ onFilterClicked = (e) => {
370
364
  e.preventDefault()
371
365
  this.shape.set({showFilters: !this.shape.showFilters})
372
366
  }