@cocreate/elements
Advanced tools
Comparing version 1.23.5 to 1.24.0
{ | ||
"name": "@cocreate/elements", | ||
"version": "1.23.5", | ||
"version": "1.24.0", | ||
"description": "Fetch content into any html element by using html5 attributes to query data stored in CoCreate headless CMS. If data is changed it will instantly reflect in html tags as changes are broadcasted in realtime", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -29,3 +29,3 @@ /******************************************************************************** | ||
import CRUD from '@cocreate/crud-client'; | ||
import { dotNotationToObject, queryData, sortData, getAttributes, getAttributeNames, checkValue } from '@cocreate/utils'; | ||
import { dotNotationToObject, queryElements, queryData, sortData, getAttributes, getAttributeNames, checkValue } from '@cocreate/utils'; | ||
import filter from '@cocreate/filter'; | ||
@@ -255,2 +255,4 @@ import render from '@cocreate/render'; | ||
function setData(element, data) { | ||
if (data.method === 'delete.object') | ||
console.log('test') | ||
if (!element) { | ||
@@ -408,15 +410,14 @@ element = getDataElements(data) | ||
} | ||
} | ||
if (index >= 0) { | ||
if (data.$filter.currentIndex === index) | ||
delete data.$filter.currentIndex | ||
data.$filter.index = index | ||
if (element.renderValue) | ||
element.renderValue(data); | ||
// render({ element, data, key: type }); | ||
else if (data) | ||
element.setValue(data) | ||
} | ||
if (index >= 0) { | ||
if (data.$filter.currentIndex === index) | ||
delete data.$filter.currentIndex | ||
data.$filter.index = index | ||
if (element.renderValue) | ||
element.renderValue(data); | ||
else if (data) | ||
element.setValue(data) | ||
} | ||
} | ||
} | ||
@@ -662,4 +663,6 @@ | ||
for (let i = 0; i < data.length; i++) { | ||
if (data[i].type === 'object' && !data[i]) { | ||
if (data[i].type === 'object' && !data[i].method) { | ||
if (typeof data[i].object === 'string') { | ||
@@ -1049,6 +1052,28 @@ if (!data[i]._id) | ||
callback: async (action) => { | ||
const data = getObject(action.element); | ||
if (data) { | ||
let elements = queryElements({ element: action.element, prefix: 'delete' }); | ||
if (elements === false) | ||
elements = [action.element] | ||
for (let i = 0; i < elements.length; i++) { | ||
const data = getObject(elements[i]); | ||
if (!data) return | ||
data.method = 'delete.' + data.type | ||
if (data.type === 'object' && typeof data[data.type] === 'string') | ||
if (elements[i].renderValue) { | ||
let selected = elements[i].querySelectorAll('.selected') | ||
data[data.type] = [] | ||
for (let j = 0; j < selected.length; j++) { | ||
let attribute = selected[j].getAttribute(data.type) | ||
if (attribute) { | ||
attribute = attribute.split(',') | ||
for (let k = 0; k < attribute.length; k++) { | ||
if (data.type === 'object') | ||
data[data.type].push({ _id: attribute[k] }) | ||
else { | ||
data[data.type].push(attribute[k]) | ||
} | ||
} | ||
} | ||
} | ||
} else if (data.type === 'object' && typeof data[data.type] === 'string') | ||
data[data.type] = { _id: data[data.type] } | ||
@@ -1066,2 +1091,2 @@ | ||
export default { init, read, save, getData, reset, elements, keys, forms, debounce, getAttributes }; | ||
export default { init, read, save, getData, getObject, reset, elements, keys, forms, debounce, getAttributes }; |
Sorry, the diff of this file is too big to display
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
191851
1237