ywana-core8 0.0.517 → 0.0.520

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ywana-core8",
3
- "version": "0.0.517",
3
+ "version": "0.0.520",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
package/src/css/html.css CHANGED
@@ -42,4 +42,16 @@ td.actions {
42
42
  */
43
43
  body > iframe[style*="2147483647"]:not([id="webpack-dev-server-client-overlay"]) {
44
44
  display: none;
45
+ }
46
+
47
+ .empty-message {
48
+ width: 100%;
49
+ height: 100%;
50
+ min-height: 10rem;
51
+ flex: 1;
52
+ display: flex;
53
+ flex-direction: column;
54
+ justify-content: center;
55
+ align-items: center;
56
+ color: var(--text-color-lighter)
45
57
  }
@@ -36,16 +36,16 @@ export const TabbedTablePage = (props) => {
36
36
  const timer = useRef(null)
37
37
  const [form, setForm] = useState(selected)
38
38
  const [tabs, setTabs] = useState([])
39
-
39
+
40
40
  useEffect(async () => {
41
41
  const field = Object.values(schema).find(field => field.tab && field.tab === true)
42
- const tabs = field.options.map(option => Object.assign({}, option, { field: field.id}))
42
+ const tabs = field.options.map(option => Object.assign({}, option, { field: field.id }))
43
43
  setTabs(tabs)
44
44
  context.changeTab(tabs[0])
45
45
  setPageContext(context)
46
46
  }, [])
47
-
48
- useEffect( async () => {
47
+
48
+ useEffect(async () => {
49
49
  if (tab) {
50
50
  const filter = { [tab.field]: tab.value }
51
51
  await pageContext.load(filter, [])
@@ -151,7 +151,7 @@ export const TabbedTablePage = (props) => {
151
151
  }
152
152
 
153
153
  function renderTabs() {
154
- const selected = tab ? tab.value : null
154
+ const selected = tab ? tab.value : null
155
155
  return (
156
156
  <Tabs selected={selected} onChange={changeTab} fillRight={true} fillLeft={false}>
157
157
  {tabs.map(tab => <Tab id={tab.value} label={tab.label} />)}
@@ -179,7 +179,7 @@ export const TabbedTablePage = (props) => {
179
179
  </menu>
180
180
  ) : null}
181
181
  <main key={id} className="table-page">
182
- <TableEditor icon={icon} title={name} tabs={renderTabs()} schema={schema} delay={delay} editable={editable} groupBy={groupBy} filter={tableFilter} actions={tableActions} canDelete={canDelete} className={tableClassName}/>
182
+ <TableEditor icon={icon} title={name} tabs={renderTabs()} schema={schema} delay={delay} editable={editable} groupBy={groupBy} filter={tableFilter} actions={tableActions} canDelete={canDelete} className={tableClassName} />
183
183
  {children ? <article>{children}</article> : null}
184
184
  </main>
185
185
  {renderAside()}
@@ -326,10 +326,10 @@ const TableFilters = (props) => {
326
326
 
327
327
  const likes = useMemo(() => {
328
328
  const fields = Object.values(schema)
329
- return fields.reduce((likes, field) => {
330
- if (field.like === true) likes.push(field.id)
331
- return likes
332
- }, [])
329
+ return fields.reduce((likes, field) => {
330
+ if (field.like === true) likes.push(field.id)
331
+ return likes
332
+ }, [])
333
333
  }, [schema])
334
334
 
335
335
  useEffect(() => {
@@ -453,6 +453,14 @@ export const TableEditor = (props) => {
453
453
  groups[groupName].push(item)
454
454
  return groups
455
455
  }, {})
456
+
457
+ if (groups.length === 0) return (
458
+ <div className='empty-message'>
459
+ <Icon icon="search_off" />
460
+ <Text>No Result Found</Text>
461
+ </div>
462
+ )
463
+
456
464
  return Object.keys(groups).map(groupName => {
457
465
  const table = {
458
466
  columns: Object.values(schema)
@@ -492,7 +500,7 @@ export const TableEditor = (props) => {
492
500
  <Header title={title} >
493
501
  <span className="size">{groupSize}</span>
494
502
  </Header>
495
- <DataTable {...table} onRowSelection={select} editable={editable} onCheckAll={check} className={className}/>
503
+ <DataTable {...table} onRowSelection={select} editable={editable} onCheckAll={check} className={className} />
496
504
  </Fragment>
497
505
  )
498
506
  })
@@ -550,7 +558,7 @@ const TableContext = (url, field, host, urlQuery) => {
550
558
 
551
559
  return filters;
552
560
  }, {}) : []
553
-
561
+
554
562
  if (this.tab) {
555
563
  filters[this.tab.field] = this.tab.value
556
564
  }
@@ -670,7 +678,7 @@ const TableAPI = (url, host) => {
670
678
  }, "")
671
679
  return query.concat(param)
672
680
  } else {
673
- return like.includes(key) ? query.concat(`${key}=%${filters[key]}%&`) : query.concat(`${key}=${filters[key]}&`)
681
+ return like.includes(key) ? query.concat(`${key}=%${filters[key]}%&`) : query.concat(`${key}=${filters[key]}&`)
674
682
  }
675
683
  }, "")
676
684
  queryParams = queryParams.concat(filterQuery)
package/src/html/table.js CHANGED
@@ -110,10 +110,19 @@ export const DataTable = (props) => {
110
110
  </tr>
111
111
  </thead>
112
112
  <tbody>
113
- {
113
+ {rows.length > 0 ?
114
114
  multiSort(rows, sortDir).map(row => (
115
115
  <DataTableRow key={row.id} row={row} columns={columns} onSelect={select} onDrop={moveRow} editable={editable} expanded={expanded} />
116
- ))
116
+ )) : (
117
+ <tr>
118
+ <td colSpan={columns.length+1}>
119
+ <div className='empty-message'>
120
+ <Icon icon="search_off" />
121
+ <Text>No Result Found</Text>
122
+ </div>
123
+ </td>
124
+ </tr>
125
+ )
117
126
  }
118
127
  </tbody>
119
128
  </table>
@@ -194,7 +203,7 @@ const EntityCellViewer = ({ id, item, value }) => {
194
203
 
195
204
  const fields = Object.values(item).filter(field => field.column === true)
196
205
  const locale = window.navigator.userLanguage || window.navigator.language;
197
-
206
+
198
207
  return fields.map(field => {
199
208
 
200
209
  let text = value[field.id]
@@ -35,7 +35,7 @@ export const TableTest = (prop) => {
35
35
  setRows(next)
36
36
  }
37
37
 
38
- const table = {
38
+ const table1 = {
39
39
  className: "xxx",
40
40
  editable: true,
41
41
  columns : [
@@ -49,9 +49,23 @@ export const TableTest = (prop) => {
49
49
  rows
50
50
  }
51
51
 
52
+ const table2 = {
53
+ className: "xxx",
54
+ editable: true,
55
+ columns : [
56
+ { id: "checked", onChange: check },
57
+ { id: "name", label: "Name", type: "String", onChange: editCell },
58
+ { id: "name", label: "Name", type: "String", sortable: true },
59
+ { id: "thumb", label: "Thumb", type: "String", format: FORMATS.IMG },
60
+ { id: "color", label: "Color", type: "String", format: FORMATS.COLOR },
61
+ { id: "date", label: "Date", type: "String", format: FORMATS.DATE },
62
+ ],
63
+ rows: []
64
+ }
65
+
52
66
  return (
53
67
  <div style={{ maxHeight: "20rem", overflow: "hidden", border: "solid 1px red", margin: "2rem" }}>
54
- <DataTable {...table} onRowSelection={select} onCheckAll={checkAll}/>
68
+ <DataTable {...table2} onRowSelection={select} onCheckAll={checkAll}/>
55
69
  </div>
56
70
  )
57
71
  }
@@ -43,6 +43,11 @@
43
43
  width: var(--column-width);
44
44
  background-color: var(--paper-color);
45
45
  height: 2.6rem;
46
+ border: solid 3px red;
47
+ }
48
+
49
+ .thisWeek {
50
+ background-color: red;
46
51
  }
47
52
 
48
53
  .date-header {
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useMemo, useState } from "react";
2
- import { DropDown, Header, Icon, Text, TextField } from "../../html";
2
+ import { DropDown, Header, Icon, Text, TextField, Button } from "../../html";
3
3
  import moment from "moment";
4
4
  import { extendMoment } from "moment-range";
5
5
  import "./Planner2.css";
@@ -21,6 +21,10 @@ export const Planner = ({ title, events = [], lanes = [], navigation = true, onS
21
21
  const [from, setFrom] = useState(config.from);
22
22
  const [to, setTo] = useState(config.to);
23
23
 
24
+ useEffect(() => {
25
+ showThisWeek()
26
+ }, [])
27
+
24
28
  useEffect(() => {
25
29
  const element = document.getElementById(focusEvent)
26
30
  if (element) element.scrollIntoView({
@@ -60,6 +64,15 @@ export const Planner = ({ title, events = [], lanes = [], navigation = true, onS
60
64
  if (onSelectCell) onSelectCell(lane, date);
61
65
  }
62
66
 
67
+ function showThisWeek() {
68
+ const element = document.querySelector(".thisMonday")
69
+ if (element) element.scrollIntoView({
70
+ behavior: 'smooth',
71
+ block: 'start',
72
+ inline: 'start'
73
+ })
74
+ }
75
+
63
76
  const period = useMemo(() => {
64
77
  const start = ranges(from, "YYYY-MM-DD");
65
78
  const end = ranges(to, "YYYY-MM-DD");
@@ -79,6 +92,8 @@ export const Planner = ({ title, events = [], lanes = [], navigation = true, onS
79
92
 
80
93
  {navigation ? (
81
94
  <Header title={label}>
95
+ &nbsp;&nbsp;
96
+ <Button label="Esta Semana" outlined action={showThisWeek}/>
82
97
  <Icon icon="chevron_right" clickable action={next} />
83
98
  <TextField id="to" type="date" label="To" value={to} onChange={(id, value) => setTo(value)} />
84
99
  <div className="expand"></div>
@@ -117,9 +132,10 @@ export const Planner = ({ title, events = [], lanes = [], navigation = true, onS
117
132
  {period.map((date) => {
118
133
  const isWekend = [0, 6].includes(date.moment.day());
119
134
  const weekend = isWekend ? "weekend" : "";
135
+ const thisWeek = moment().startOf('week').isSame(date.moment, "week") ? "thisWeek" : "";
120
136
  return (
121
137
  <div className="column-header">
122
- <div className={`date-header ${weekend}`}>
138
+ <div className={`date-header ${weekend} ${thisWeek}`}>
123
139
  <Text use="headline6">{date.moment.format("DD")}</Text>
124
140
  &nbsp;
125
141
  <Text use="caption">{date.moment.format("ddd")}</Text>
@@ -206,9 +222,13 @@ const PlannerCell = ({ lane, events, date, disabled = false, onAdd, onDelete, on
206
222
 
207
223
  const isWekend = [0, 6].includes(date.moment.day());
208
224
  const weekend = isWekend ? "weekend" : "";
225
+
226
+ const today = moment()
227
+ var weekStart = today.clone().startOf('week')
228
+ const thisMonday = (date.moment.isSame(weekStart)) ? "thisMonday" : ""
209
229
  const dragOverStyle = dragOver ? "drag-over" : ""
210
230
  return (
211
- <div className={`cell ${weekend} ${dragOverStyle}`} onDragOver={onDragOver} onDragLeave={onDragLeave} onDrop={drop} onClick={select}>
231
+ <div className={`cell ${thisMonday} ${weekend} ${dragOverStyle}`} onDragOver={onDragOver} onDragLeave={onDragLeave} onDrop={drop} onClick={select}>
212
232
  {events.map(event => {
213
233
  const { Renderer = EventCard } = event
214
234
  return <Renderer key={event.id} event={event} />
@@ -49,8 +49,8 @@ const PlannerTest = (prop) => {
49
49
  lanes={lanes}
50
50
  events={events}
51
51
  navigation={true}
52
- onSelectCell={console.log}
53
- focusEvent={event}
52
+ onSelectCell={console.log}
53
+
54
54
  onChange={(data) => console.log('D&D', data)}
55
55
  >
56
56
 
@@ -38,6 +38,13 @@
38
38
  border-bottom: solid 1px var(--divider-color);
39
39
  }
40
40
 
41
+ .planner .date-header.thisWeek {
42
+ background-color: rgb(10, 176, 35);
43
+ border-radius: 3px;
44
+ padding: .2rem;
45
+ color: var(--paper-color);
46
+ }
47
+
41
48
  .planner .row-header {
42
49
  width: var(--column-width);
43
50
  background-color: var(--paper-color);