@aexol/slothking-admin
Advanced tools
Comparing version 0.1.18 to 0.1.19
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const classnames = require("classnames"); | ||
const components_1 = require("./components"); | ||
const slothking_components_1 = require("@aexol/slothking-components"); | ||
const slothking_syncano_1 = require("@aexol/slothking-syncano"); | ||
const Containers_1 = require("./Containers"); | ||
const unstated_1 = require("unstated"); | ||
let styles = require('./Admin.css'); | ||
class SyncanoAdmin extends React.Component { | ||
constructor() { | ||
super(...arguments); | ||
this.state = { | ||
var React = require("react"); | ||
var classnames = require("classnames"); | ||
var components_1 = require("./components"); | ||
var slothking_components_1 = require("@aexol/slothking-components"); | ||
var slothking_syncano_1 = require("@aexol/slothking-syncano"); | ||
var Containers_1 = require("./Containers"); | ||
var unstated_1 = require("unstated"); | ||
var styles = require('./Admin.css'); | ||
var SyncanoAdmin = (function (_super) { | ||
__extends(SyncanoAdmin, _super); | ||
function SyncanoAdmin() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.state = { | ||
showCategories: null | ||
}; | ||
return _this; | ||
} | ||
render() { | ||
const { showCategories } = this.state; | ||
const { rest: { models } } = this.props; | ||
return (React.createElement(unstated_1.Subscribe, { to: [slothking_syncano_1.Auth, Containers_1.Schema, slothking_syncano_1.Rest] }, (auth, schemas, rest) => { | ||
const { valid } = auth.state; | ||
SyncanoAdmin.prototype.render = function () { | ||
var _this = this; | ||
var showCategories = this.state.showCategories; | ||
var models = this.props.rest.models; | ||
return (React.createElement(unstated_1.Subscribe, { to: [slothking_syncano_1.Auth, Containers_1.Schema, slothking_syncano_1.Rest] }, function (auth, schemas, rest) { | ||
var valid = auth.state.valid; | ||
if (valid === false || rest.state.isAdmin === false) { | ||
@@ -42,7 +55,7 @@ return (React.createElement("div", { className: styles.SyncanoAdmin }, | ||
return (React.createElement("div", { className: [styles.SyncanoAdmin, styles.ContentAdmin].join(' ') }, | ||
React.createElement("div", { className: classnames({ | ||
[styles['open-categories']]: true, | ||
[styles['arrow-toggle']]: showCategories | ||
}), onClick: () => { | ||
this.setState({ | ||
React.createElement("div", { className: classnames((_a = {}, | ||
_a[styles['open-categories']] = true, | ||
_a[styles['arrow-toggle']] = showCategories, | ||
_a)), onClick: function () { | ||
_this.setState({ | ||
showCategories: !showCategories | ||
@@ -52,16 +65,18 @@ }); | ||
React.createElement(components_1.Arrow, null)), | ||
React.createElement("div", { className: classnames({ | ||
[styles.SyncanoCategories]: true, | ||
[styles['show-categories']]: showCategories | ||
}) }, | ||
React.createElement("div", { className: classnames((_b = {}, | ||
_b[styles.SyncanoCategories] = true, | ||
_b[styles['show-categories']] = showCategories, | ||
_b)) }, | ||
React.createElement("div", { className: styles.SyncanoLogoCompany }, | ||
React.createElement("img", { src: require('./images/logo.png') })), | ||
React.createElement("div", { className: styles.Models }, models.map((m) => React.createElement("div", null, m.name))), | ||
React.createElement("div", { className: styles.Models }, models.map(function (m) { return React.createElement("div", null, m.name); })), | ||
React.createElement("div", { className: [styles.SyncanoCategory, styles.LogOut].join(' '), onClick: auth.logout }, "log out")), | ||
React.createElement("div", { className: styles.SyncanoContainer }, | ||
React.createElement(components_1.AdminList, { model: rest.state.models['propertytype'], references: [], schema: schemas.state.schema.find((sc) => sc.name === 'propertytype'), onAdd: (e) => rest.add('propertytype', e), onUpdate: (id, e) => rest.update('propertytype', id, e), onDelete: (id) => rest.remove('propertytype', id) })))); | ||
React.createElement(components_1.AdminList, { model: rest.state.models['propertytype'], references: [], schema: schemas.state.schema.find(function (sc) { return sc.name === 'propertytype'; }), onAdd: function (e) { return rest.add('propertytype', e); }, onUpdate: function (id, e) { return rest.update('propertytype', id, e); }, onDelete: function (id) { return rest.remove('propertytype', id); } })))); | ||
var _a, _b; | ||
})); | ||
} | ||
} | ||
}; | ||
return SyncanoAdmin; | ||
}(React.Component)); | ||
exports.SyncanoAdmin = SyncanoAdmin; | ||
//# sourceMappingURL=Admin.js.map |
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const ModalSet_1 = require("../modal/ModalSet"); | ||
const slothking_form_1 = require("@aexol/slothking-form"); | ||
const formMappings_1 = require("./formMappings"); | ||
let styles = require('./List.css'); | ||
let multiSelectStyles = require('./MultiSelect.css'); | ||
class AdminList extends React.Component { | ||
constructor() { | ||
super(...arguments); | ||
this.state = { | ||
var React = require("react"); | ||
var ModalSet_1 = require("../modal/ModalSet"); | ||
var slothking_form_1 = require("@aexol/slothking-form"); | ||
var formMappings_1 = require("./formMappings"); | ||
var styles = require('./List.css'); | ||
var multiSelectStyles = require('./MultiSelect.css'); | ||
var AdminList = (function (_super) { | ||
__extends(AdminList, _super); | ||
function AdminList() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.state = { | ||
filtr: [], | ||
@@ -19,14 +38,19 @@ activeFilters: [], | ||
}; | ||
return _this; | ||
} | ||
render() { | ||
const { model, schema, references, onAdd, onDelete, onUpdate } = this.props; | ||
let { values, open, filtr, display } = this.state; | ||
AdminList.prototype.render = function () { | ||
var _this = this; | ||
var _a = this.props, model = _a.model, schema = _a.schema, references = _a.references, onAdd = _a.onAdd, onDelete = _a.onDelete, onUpdate = _a.onUpdate; | ||
var _b = this.state, values = _b.values, open = _b.open, filtr = _b.filtr, display = _b.display; | ||
if (!model) { | ||
return React.createElement("div", { className: styles.ChooseModel }, "Choose a model"); | ||
} | ||
let renderedObjects = model; | ||
var renderedObjects = model; | ||
if (filtr) { | ||
let filterKeys = Object.keys(filtr).filter((f) => this.state.activeFilters.find((a) => a === f)); | ||
var filterKeys = Object.keys(filtr).filter(function (f) { | ||
return _this.state.activeFilters.find(function (a) { return a === f; }); | ||
}); | ||
if (filterKeys.length) { | ||
for (var f of filterKeys) { | ||
for (var _i = 0, filterKeys_1 = filterKeys; _i < filterKeys_1.length; _i++) { | ||
var f = filterKeys_1[_i]; | ||
renderedObjects = slothking_form_1.filterRules({ | ||
@@ -36,3 +60,3 @@ value: filtr[f], | ||
name: f, | ||
type: schema.fields.find((field) => field.name === f).type | ||
type: schema.fields.find(function (field) { return field.name === f; }).type | ||
}); | ||
@@ -42,12 +66,9 @@ } | ||
} | ||
let fields = schema.fields; | ||
fields = formMappings_1.syncanoRelations({ fields, models: references }); | ||
let filterFields = [{ label: 'id', value: 'id' }]; | ||
filterFields = [ | ||
...filterFields, | ||
...schema.fields.filter((f) => f.type === 'string' || f.type === 'text').map((f) => ({ | ||
label: f.name, | ||
value: f.name | ||
})) | ||
]; | ||
var fields = schema.fields; | ||
fields = formMappings_1.syncanoRelations({ fields: fields, models: references }); | ||
var filterFields = [{ label: 'id', value: 'id' }]; | ||
filterFields = filterFields.concat(schema.fields.filter(function (f) { return f.type === 'string' || f.type === 'text'; }).map(function (f) { return ({ | ||
label: f.name, | ||
value: f.name | ||
}); })); | ||
return (React.createElement("div", { className: styles.SyncanoManage }, | ||
@@ -57,17 +78,18 @@ React.createElement("div", { className: styles.SyncanoFilters }, | ||
React.createElement("div", { className: styles.MultiSelectSearchFields }, schema.fields | ||
.filter((f) => this.state.activeFilters.find((a) => a === f.name)) | ||
.map((f) => (React.createElement("input", { key: f.name, type: "text", placeholder: f.name, onChange: (e) => { | ||
this.setState({ | ||
filtr: Object.assign({}, this.state.filtr, { [f.name]: e.target.value }) | ||
.filter(function (f) { return _this.state.activeFilters.find(function (a) { return a === f.name; }); }) | ||
.map(function (f) { return (React.createElement("input", { key: f.name, type: "text", placeholder: f.name, onChange: function (e) { | ||
_this.setState({ | ||
filtr: __assign({}, _this.state.filtr, (_a = {}, _a[f.name] = e.target.value, _a)) | ||
}); | ||
} })))), | ||
React.createElement(slothking_form_1.MultiSelect, { styles: multiSelectStyles, options: filterFields, multi: true, value: this.state.activeFilters, onChange: (activeFilters) => { | ||
var _a; | ||
} })); })), | ||
React.createElement(slothking_form_1.MultiSelect, { styles: multiSelectStyles, options: filterFields, multi: true, value: this.state.activeFilters, onChange: function (activeFilters) { | ||
console.log(activeFilters); | ||
this.setState({ | ||
_this.setState({ | ||
activeFilters: activeFilters || [] | ||
}); | ||
}, placeholder: "Filter by.." }), | ||
React.createElement(slothking_form_1.MultiSelect, { onChange: (e) => { | ||
React.createElement(slothking_form_1.MultiSelect, { onChange: function (e) { | ||
console.log(e); | ||
this.setState({ | ||
_this.setState({ | ||
display: e, | ||
@@ -77,4 +99,4 @@ search: '' | ||
}, styles: multiSelectStyles, placeholder: "Display", value: display, options: filterFields })), | ||
React.createElement("div", { className: styles.AddButton, onClick: () => { | ||
this.setState({ | ||
React.createElement("div", { className: styles.AddButton, onClick: function () { | ||
_this.setState({ | ||
open: 'add' | ||
@@ -85,5 +107,5 @@ }); | ||
React.createElement("div", { className: styles.Vertical }))), | ||
React.createElement("div", { className: styles.SyncanoList }, renderedObjects.map((m) => (React.createElement("div", { className: styles.SyncanoObject, key: m.id }, | ||
React.createElement("div", { onClick: () => { | ||
this.setState({ | ||
React.createElement("div", { className: styles.SyncanoList }, renderedObjects.map(function (m) { return (React.createElement("div", { className: styles.SyncanoObject, key: m.id }, | ||
React.createElement("div", { onClick: function () { | ||
_this.setState({ | ||
open: 'delete', | ||
@@ -93,27 +115,27 @@ values: { id: m.id } | ||
}, className: styles.deleteButton }, "\u00D7"), | ||
React.createElement("div", { className: styles.displayName, onClick: () => { | ||
this.setState({ | ||
React.createElement("div", { className: styles.displayName, onClick: function () { | ||
_this.setState({ | ||
open: 'update', | ||
values: Object.assign({}, m) | ||
values: __assign({}, m) | ||
}); | ||
} }, display ? m[display] || m.id : m.id))))), | ||
React.createElement(ModalSet_1.default, { name: schema.name, fields: fields, values: values, open: open, toggle: (o) => { | ||
this.setState({ | ||
} }, display ? m[display] || m.id : m.id))); })), | ||
React.createElement(ModalSet_1.default, { name: schema.name, fields: fields, values: values, open: open, toggle: function (o) { | ||
_this.setState({ | ||
open: o | ||
}); | ||
}, onAdd: (e) => { | ||
onAdd(e).then((r) => { | ||
this.setState({ | ||
}, onAdd: function (e) { | ||
onAdd(e).then(function (r) { | ||
_this.setState({ | ||
open: '' | ||
}); | ||
}); | ||
}, onUpdate: (id, e) => { | ||
onUpdate(id, e).then((r) => { | ||
this.setState({ | ||
}, onUpdate: function (id, e) { | ||
onUpdate(id, e).then(function (r) { | ||
_this.setState({ | ||
open: '' | ||
}); | ||
}); | ||
}, onDelete: (id) => { | ||
onDelete(id).then((r) => { | ||
this.setState({ | ||
}, onDelete: function (id) { | ||
onDelete(id).then(function (r) { | ||
_this.setState({ | ||
open: '' | ||
@@ -123,5 +145,6 @@ }); | ||
} }))); | ||
} | ||
} | ||
}; | ||
return AdminList; | ||
}(React.Component)); | ||
exports.AdminList = AdminList; | ||
//# sourceMappingURL=AdminList.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
exports.Arrow = () => (React.createElement("svg", { version: "1.1", id: "Capa_1", x: "0px", y: "0px", width: "15px", height: "15px", viewBox: "0 0 284.935 284.936" }, | ||
React.createElement("path", { d: "M222.701,135.9L89.652,2.857C87.748,0.955,85.557,0,83.084,0c-2.474,0-4.664,0.955-6.567,2.857L62.244,17.133\nc-1.906,1.903-2.855,4.089-2.855,6.567c0,2.478,0.949,4.664,2.855,6.567l112.204,112.204L62.244,254.677\nc-1.906,1.903-2.855,4.093-2.855,6.564c0,2.477,0.949,4.667,2.855,6.57l14.274,14.271c1.903,1.905,4.093,2.854,6.567,2.854\nc2.473,0,4.663-0.951,6.567-2.854l133.042-133.044c1.902-1.902,2.854-4.093,2.854-6.567S224.603,137.807,222.701,135.9z", fill: "#FFFFFF" }))); | ||
var React = require("react"); | ||
exports.Arrow = function () { return (React.createElement("svg", { version: "1.1", id: "Capa_1", x: "0px", y: "0px", width: "15px", height: "15px", viewBox: "0 0 284.935 284.936" }, | ||
React.createElement("path", { d: "M222.701,135.9L89.652,2.857C87.748,0.955,85.557,0,83.084,0c-2.474,0-4.664,0.955-6.567,2.857L62.244,17.133\nc-1.906,1.903-2.855,4.089-2.855,6.567c0,2.478,0.949,4.664,2.855,6.567l112.204,112.204L62.244,254.677\nc-1.906,1.903-2.855,4.093-2.855,6.564c0,2.477,0.949,4.667,2.855,6.57l14.274,14.271c1.903,1.905,4.093,2.854,6.567,2.854\nc2.473,0,4.663-0.951,6.567-2.854l133.042-133.044c1.902-1.902,2.854-4.093,2.854-6.567S224.603,137.807,222.701,135.9z", fill: "#FFFFFF" }))); }; | ||
//# sourceMappingURL=Arrow.js.map |
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
@@ -12,12 +20,13 @@ var t = {}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const moment = require("moment"); | ||
exports.syncanoRelations = ({ fields, models }) => { | ||
let newFields = fields.map((f) => { | ||
let { filter_index, order_index, unique } = f, field = __rest(f, ["filter_index", "order_index", "unique"]); | ||
var moment = require("moment"); | ||
exports.syncanoRelations = function (_a) { | ||
var fields = _a.fields, models = _a.models; | ||
var newFields = fields.map(function (f) { | ||
var filter_index = f.filter_index, order_index = f.order_index, unique = f.unique, field = __rest(f, ["filter_index", "order_index", "unique"]); | ||
if (['relation', 'reference'].indexOf(f.type) !== -1) { | ||
let ref = models.find((r) => r.name === field.target); | ||
field = Object.assign({}, field, { type: 'select', values: ref.objects.map((o) => ({ label: o[ref.display], value: o.id })) }); | ||
var ref_1 = models.find(function (r) { return r.name === field.target; }); | ||
field = __assign({}, field, { type: 'select', values: ref_1.objects.map(function (o) { return ({ label: o[ref_1.display], value: o.id }); }) }); | ||
} | ||
if (f.type === 'geopoint') { | ||
field = Object.assign({}, field, { type: 'object' }); | ||
field = __assign({}, field, { type: 'object' }); | ||
} | ||
@@ -28,5 +37,6 @@ return field; | ||
}; | ||
exports.syncanoReceive = ({ fields, models, values }) => { | ||
let newValues = Object.assign({}, values); | ||
fields.map((f) => { | ||
exports.syncanoReceive = function (_a) { | ||
var fields = _a.fields, models = _a.models, values = _a.values; | ||
var newValues = __assign({}, values); | ||
fields.map(function (f) { | ||
if (f.type === 'datetime' && values[f.name]) { | ||
@@ -38,5 +48,6 @@ newValues[f.name] = moment(values[f.name]); | ||
}; | ||
exports.syncanoSend = ({ fields, values }) => { | ||
let newValues = Object.assign({}, values); | ||
fields.map((f) => { | ||
exports.syncanoSend = function (_a) { | ||
var fields = _a.fields, values = _a.values; | ||
var newValues = __assign({}, values); | ||
fields.map(function (f) { | ||
if (f.type === 'datetime' && values[f.name]) { | ||
@@ -43,0 +54,0 @@ newValues[f.name] = values[f.name].toISOString(); |
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const slothking_form_1 = require("@aexol/slothking-form"); | ||
let styles = require('./Login.css'); | ||
const Wrapper = ({ children, styles }) => React.createElement("div", { className: styles.FieldWrapper }, children); | ||
const Submit = ({ styles }) => React.createElement("input", { className: styles.Submit, type: "submit", value: 'Sign in' }); | ||
exports.Login = ({ styles: overrideStyles, onLogin }) => { | ||
var React = require("react"); | ||
var slothking_form_1 = require("@aexol/slothking-form"); | ||
var styles = require('./Login.css'); | ||
var Wrapper = function (_a) { | ||
var children = _a.children, styles = _a.styles; | ||
return React.createElement("div", { className: styles.FieldWrapper }, children); | ||
}; | ||
var Submit = function (_a) { | ||
var styles = _a.styles; | ||
return React.createElement("input", { className: styles.Submit, type: "submit", value: 'Sign in' }); | ||
}; | ||
exports.Login = function (_a) { | ||
var overrideStyles = _a.styles, onLogin = _a.onLogin; | ||
if (overrideStyles) { | ||
@@ -19,3 +34,3 @@ styles = overrideStyles; | ||
type: 'string', | ||
styles | ||
styles: styles | ||
}, | ||
@@ -26,5 +41,5 @@ { | ||
inputType: 'password', | ||
styles | ||
styles: styles | ||
} | ||
], AlternativeWrapper: (props) => React.createElement(Wrapper, Object.assign({}, props, { styles: styles })), className: styles.FormGen, Submit: (props) => React.createElement(Submit, Object.assign({}, props, { styles: styles })), validate: (e) => { | ||
], AlternativeWrapper: function (props) { return React.createElement(Wrapper, __assign({}, props, { styles: styles })); }, className: styles.FormGen, Submit: function (props) { return React.createElement(Submit, __assign({}, props, { styles: styles })); }, validate: function (e) { | ||
onLogin(e.username, e.password); | ||
@@ -31,0 +46,0 @@ }, submitText: 'Sign in' }))); |
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const unstated_1 = require("unstated"); | ||
const slothking_syncano_1 = require("@aexol/slothking-syncano"); | ||
class Schema extends unstated_1.Container { | ||
constructor() { | ||
super(); | ||
this.state = { | ||
var unstated_1 = require("unstated"); | ||
var slothking_syncano_1 = require("@aexol/slothking-syncano"); | ||
var Schema = (function (_super) { | ||
__extends(Schema, _super); | ||
function Schema() { | ||
var _this = _super.call(this) || this; | ||
_this.state = { | ||
schema: [] | ||
}; | ||
slothking_syncano_1.s.post('rest-framework/schema', {}).then((schema) => { | ||
this.setState({ | ||
schema | ||
slothking_syncano_1.s.post('rest-framework/schema', {}).then(function (schema) { | ||
_this.setState({ | ||
schema: schema | ||
}); | ||
}); | ||
return _this; | ||
} | ||
} | ||
return Schema; | ||
}(unstated_1.Container)); | ||
exports.Schema = Schema; | ||
//# sourceMappingURL=Containers.js.map |
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const slothking_components_1 = require("@aexol/slothking-components"); | ||
const slothking_form_1 = require("@aexol/slothking-form"); | ||
let styles = require('./FormComponents.css'); | ||
class AddModal extends React.Component { | ||
render() { | ||
const { isOpen, toggle, fields, text, onAdd } = this.props; | ||
var React = require("react"); | ||
var slothking_components_1 = require("@aexol/slothking-components"); | ||
var slothking_form_1 = require("@aexol/slothking-form"); | ||
var styles = require('./FormComponents.css'); | ||
var AddModal = (function (_super) { | ||
__extends(AddModal, _super); | ||
function AddModal() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
AddModal.prototype.render = function () { | ||
var _a = this.props, isOpen = _a.isOpen, toggle = _a.toggle, fields = _a.fields, text = _a.text, onAdd = _a.onAdd; | ||
return (React.createElement(slothking_components_1.Modal, { isOpen: isOpen, toggle: toggle }, | ||
React.createElement(slothking_components_1.ModalHeader, { toggle: toggle }, text), | ||
React.createElement(slothking_components_1.ModalBody, null, | ||
React.createElement(slothking_form_1.Form, { className: styles.FormGen, fields: fields.map((f) => (Object.assign({}, f, { styles }))), Submit: () => React.createElement("input", { type: "submit", value: "Add", className: styles.Submit }), validate: (e) => { | ||
React.createElement(slothking_form_1.Form, { className: styles.FormGen, fields: fields.map(function (f) { return (__assign({}, f, { styles: styles })); }), Submit: function () { return React.createElement("input", { type: "submit", value: "Add", className: styles.Submit }); }, validate: function (e) { | ||
onAdd(e); | ||
} })))); | ||
} | ||
} | ||
}; | ||
return AddModal; | ||
}(React.Component)); | ||
exports.AddModal = AddModal; | ||
//# sourceMappingURL=AddModal.js.map |
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const slothking_components_1 = require("@aexol/slothking-components"); | ||
class DeleteModal extends React.Component { | ||
render() { | ||
const { isOpen, toggle, values, text, warning, name, onDelete } = this.props; | ||
var React = require("react"); | ||
var slothking_components_1 = require("@aexol/slothking-components"); | ||
var DeleteModal = (function (_super) { | ||
__extends(DeleteModal, _super); | ||
function DeleteModal() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
DeleteModal.prototype.render = function () { | ||
var _a = this.props, isOpen = _a.isOpen, toggle = _a.toggle, values = _a.values, text = _a.text, warning = _a.warning, name = _a.name, onDelete = _a.onDelete; | ||
return (React.createElement(slothking_components_1.Modal, { isOpen: isOpen, toggle: toggle }, | ||
@@ -12,3 +26,3 @@ React.createElement(slothking_components_1.ModalHeader, { toggle: toggle }, text), | ||
React.createElement(slothking_components_1.ModalFooter, null, | ||
React.createElement("button", { onClick: () => { | ||
React.createElement("button", { onClick: function () { | ||
onDelete(values.id); | ||
@@ -19,8 +33,9 @@ } }, | ||
' ', | ||
React.createElement("button", { onClick: () => { | ||
React.createElement("button", { onClick: function () { | ||
toggle(); | ||
} }, "Cancel")))); | ||
} | ||
} | ||
}; | ||
return DeleteModal; | ||
}(React.Component)); | ||
exports.DeleteModal = DeleteModal; | ||
//# sourceMappingURL=DeleteModal.js.map |
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const AddModal_1 = require("./AddModal"); | ||
const DeleteModal_1 = require("./DeleteModal"); | ||
const UpdateModal_1 = require("./UpdateModal"); | ||
const React = require("react"); | ||
class ModalSet extends React.Component { | ||
render() { | ||
const { name, fields, values, open, toggle, onAdd, onUpdate, onDelete } = this.props; | ||
const { addText = `Add ${name}`, updateText = `Edit ${name}`, deleteText = `Do you really want to delete ${name}?` } = this.props; | ||
const deleteText1 = `Delete ${name}`; | ||
var AddModal_1 = require("./AddModal"); | ||
var DeleteModal_1 = require("./DeleteModal"); | ||
var UpdateModal_1 = require("./UpdateModal"); | ||
var React = require("react"); | ||
var ModalSet = (function (_super) { | ||
__extends(ModalSet, _super); | ||
function ModalSet() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
ModalSet.prototype.render = function () { | ||
var _a = this.props, name = _a.name, fields = _a.fields, values = _a.values, open = _a.open, toggle = _a.toggle, onAdd = _a.onAdd, onUpdate = _a.onUpdate, onDelete = _a.onDelete; | ||
var _b = this.props, _c = _b.addText, addText = _c === void 0 ? "Add " + name : _c, _d = _b.updateText, updateText = _d === void 0 ? "Edit " + name : _d, _e = _b.deleteText, deleteText = _e === void 0 ? "Do you really want to delete " + name + "?" : _e; | ||
var deleteText1 = "Delete " + name; | ||
return (React.createElement("div", { className: "ModalSet" }, | ||
@@ -16,5 +30,6 @@ React.createElement(AddModal_1.AddModal, { fields: fields, isOpen: open === 'add', name: name, text: addText, toggle: toggle, onAdd: onAdd }), | ||
React.createElement(DeleteModal_1.DeleteModal, { values: values, isOpen: open === 'delete', name: name, text: deleteText1, toggle: toggle, warning: deleteText, onDelete: onDelete }))); | ||
} | ||
} | ||
}; | ||
return ModalSet; | ||
}(React.Component)); | ||
exports.default = ModalSet; | ||
//# sourceMappingURL=ModalSet.js.map |
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const slothking_form_1 = require("@aexol/slothking-form"); | ||
const slothking_components_1 = require("@aexol/slothking-components"); | ||
let styles = require('./FormComponents.css'); | ||
class UpdateModal extends React.Component { | ||
render() { | ||
const { isOpen, toggle, fields, values, name, onUpdate } = this.props; | ||
var React = require("react"); | ||
var slothking_form_1 = require("@aexol/slothking-form"); | ||
var slothking_components_1 = require("@aexol/slothking-components"); | ||
var styles = require('./FormComponents.css'); | ||
var UpdateModal = (function (_super) { | ||
__extends(UpdateModal, _super); | ||
function UpdateModal() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
UpdateModal.prototype.render = function () { | ||
var _a = this.props, isOpen = _a.isOpen, toggle = _a.toggle, fields = _a.fields, values = _a.values, name = _a.name, onUpdate = _a.onUpdate; | ||
return (React.createElement(slothking_components_1.Modal, { isOpen: isOpen, toggle: toggle }, | ||
React.createElement(slothking_components_1.ModalHeader, { toggle: toggle }, `Edit ${name}`), | ||
React.createElement(slothking_components_1.ModalHeader, { toggle: toggle }, "Edit " + name), | ||
React.createElement(slothking_components_1.ModalBody, null, | ||
React.createElement(slothking_form_1.Form, { className: styles.FormGen, fields: fields.map((f) => (Object.assign({}, f, { styles }))), Submit: () => React.createElement("input", { type: "submit", value: "Edit", className: styles.Submit }), validate: (e) => { | ||
React.createElement(slothking_form_1.Form, { className: styles.FormGen, fields: fields.map(function (f) { return (__assign({}, f, { styles: styles })); }), Submit: function () { return React.createElement("input", { type: "submit", value: "Edit", className: styles.Submit }); }, validate: function (e) { | ||
onUpdate(values.id, e); | ||
}, values: values })))); | ||
} | ||
} | ||
}; | ||
return UpdateModal; | ||
}(React.Component)); | ||
exports.UpdateModal = UpdateModal; | ||
//# sourceMappingURL=UpdateModal.js.map |
{ | ||
"name": "@aexol/slothking-admin", | ||
"version": "0.1.18", | ||
"version": "0.1.19", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Slothking admin", |
{ | ||
"compilerOptions": { | ||
"sourceMap": true, | ||
"target": "es6", | ||
"target": "es5", | ||
"jsx": "react", | ||
@@ -6,0 +6,0 @@ "module": "commonjs", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
338604
2420