Undefined method `gsub' for #<Hash:0x00007fed774d2a3> (NoMethodError) - jekyll

I am trying to hook up my Jekyll installation with NetlifyCMS. I am using a custom theme that works fine without the CMS part, however when I integrate as per the NetflifyCMS docs I get this error.
~/.rvm/gems/ruby-2.5.1/gems/jekyll-3.4.1/lib/jekyll/collection.rb:158:in `sanitize_label': undefined method `gsub' for #<Hash:0x00007fed774d2a3
I am running this on a Mac OSX and here is my config.yml is. The relevant section is the collection section:
collections:
- name: 'docs'
output: true
label: 'Docs'
folder: '_docs/'
create: true
slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
editor:
preview: false
fields:
- { label: 'Layout', name: 'layout', widget: 'hidden', default: 'post' }
- { label: 'Title', name: 'title', widget: 'string' }
- { label: 'Publish Date', name: 'date', widget: 'datetime' }
- { label: 'Body', name: 'body', widget: 'markdown' }
- name: 'faqs'
output: false
label: 'Faqs'
folder: '_faqs/'
create: true
slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
editor:
preview: false
fields:
- { label: 'Layout', name: 'layout', widget: 'hidden', default: 'post' }
- { label: 'Title', name: 'title', widget: 'string' }
- { label: 'Publish Date', name: 'date', widget: 'datetime' }
- { label: 'Body', name: 'body', widget: 'markdown' }
- name: 'changelogs'
output: false
- name: 'blog'
output: true
label: 'Blog'
folder: '_posts/'
create: true
slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
editor:
preview: false
fields:
- { label: 'Layout', name: 'layout', widget: 'hidden', default: 'post' }
- { label: 'Title', name: 'title', widget: 'string' }
- { label: 'Publish Date', name: 'date', widget: 'datetime' }
- { label: 'Body', name: 'body', widget: 'markdown' }

Found the problem. NetlifyCMS docs weren't so clear. These collections should have been put in the ./admin/config.yml and I was putting them in the main config.yml file.

Related

JqxGrid filter is lost after I reload the page

I am working with an overview page, where I use JqxGrid to display all the items in our company. You can click on an item to go to the next page where you can view the details of this item. If you set a filter in the overview page and go to the detail page you lose this filter. Which is not most user-friendly. I was wondering if anybody knows how I could prevent this from happening? I tried jq cookies already but it doesnt seem to work.
$(document).ready(function () {
var sourcePO =
{
datatype: "xml",
datafields: [
{ name: 'Name', type: 'string'},
{ name: 'ID', type: 'string'},
{ name: 'Manufacturer', type: 'string'},
{ name: 'Application', type: 'string'},
{ name: 'Version', type: 'string'},
{ name: 'Status', type: 'string'},
{ name: 'Product', type: 'string'},
{ name: 'Requester', type: 'string'}
],
root: "Data",
record: "record",
id: 'id',
url: "Data.xml",
};
var dataAdapterPO = new $.jqx.dataAdapter(sourcePO);
var DocumentHeight = $(document).height();
$("#jqxgridPO").jqxGrid(
{
theme: 'metro',
width: '100%',
height: (DocumentHeight - 250),
source: dataAdapterPO,
showfilterrow: true,
filterable: true,
sortable: true,
selectionmode: 'singlerow',
columnsresize: true,
columns: [
{ text: 'Name', filtertype: 'textbox', datafield: 'Name', width: '11%' },
{ text: 'ID', filtertype: 'textbox', datafield: 'ID', width: '11%' },
{ text: 'Manufacturer', filtertype: 'textbox', datafield: 'Manufacturer', width: '11%' },
{ text: 'Application', filtertype: 'textbox', datafield: 'Application', width: '11%' },
{ text: 'Version', filtertype: 'textbox', datafield: 'Version', width: '4%' },
{ text: 'Status', filtertype: 'checkedlist', datafield: 'Status', width: '7%' },
{ text: 'Product', filtertype: 'textbox', datafield: 'Product', width: '7%' },
{ text: 'Requester', filtertype: 'textbox', datafield: 'Requester', width: '10%' },
]
}
);
$("#jqxgridPO").on("rowdoubleclick", function (event) {
var data = $('#jqxgridPO').jqxGrid('getrowdata', event.args.rowindex);
window.location.assign("../Productdetail.php?id=" + data.Name + data.ID);
});
Does anybody have any idea on how I keep the filters after clicking on a product and leaving for the product webpage? Particularly the checkbox type filters.
Thank you!
Why not have your page just hide the Grid and show the product details in a Modal JQXWindow, when the modal window closes, show your grid again.

Translating form labels inside json with i18n (react)

I'm using i18n(v9) to translate a lot of text in a big react project. It's working as intended in cases like:
<Intro
title={details.title}
subtitle={t('resume-upload subtitle')}
description={t('resume-upload description 2')}
/>
However, In a form component that uses these 2 imports:
import { Form } from 'mobx-react-form';
import validatorjs from 'validatorjs';
When I try to translate labels within the code like this:
setup() {
const { t } = this.props;
return {
fields: [
{
name: 'step',
value: 0
},
{
name: 'firstName',
label: t('Firstname'),
rules: 'required|string|between:2,25'
},
{
name: 'lastName',
label: t('Achternaam'),
rules: 'required|string|between:2,25'
},
{
name: 'emailaddress',
label: t('Email'),
rules: 'required|email|string'
},
{
name: 'phonenumber',
label: t('Telephone number'),
rules: 'required|string|telephone'
},
{
name: 'cv',
label: t('resume')
},
{
name: 'terms',
label: 'Terms',
value: false
},
{
name: 'newFile',
label: '',
value: true
},
{
name: 'noFile',
label: '',
value: false
}
]
};
}
}
export default withNamespaces()(UploadForm);
The t function gives an error in a parent file:
TypeError: form.values is not a function
Is there a way to translate json files like the way I'm attempting?

Sails/Waterline Populate doesn't work as expected

I'm bangin' my head against the wall in the last hours, and I can't figure out a solution to my problem. In my sails models, I have 2 one-to-many associations. 'A' model can have many 'B', and 'B' model can have many 'C'. In my controller, when I do a.find().populate('b') (...) it returns me the entire collection of A model, but populate each entry of A model with only one B, which doesn't match the current dataset I have in my database(mysql). And doesn't populate the C entries in the B model. In other words, I'm trying to achieve something like nested population.
It's something wrong with the Controller code, right? How can I make this work?
Thanks in advance!
EDIT:
Company.js
module.exports = {
identity: 'company',
attributes: {
name: {
type: 'string',
required: true
},
address: {
type: 'string',
required: true
},
zip_code: {
type: 'string',
required: true
},
city: {
type: 'string',
required: true
},
nif: {
type: 'integer',
required: true,
minLength: 9
},
country: {
type: 'string',
required: true
},
phone_number: {
type: 'string',
required: true
},
email: {
type: 'email',
required: true
},
facilities: {
collection: 'facility',
references: 'facility',
on: 'id',
via: 'company'
}
}
};
Facility.js
module.exports = {
identity: 'facility',
attributes: {
company: {
columnName: 'id_company',
model: 'company'
},
warehouses: {
collection: 'warehouse',
references: 'warehouse',
on: 'id',
via: 'facility'
},
name: {
type: 'string',
required: true
},
address: {
type: 'string',
required: true
},
zip_code: {
type: 'string',
required: true
},
city: {
type: 'string',
required: true
},
country: {
type: 'string',
required: true
},
phone_number: {
type: 'string',
},
email: {
type: 'email',
},
longitude: {
type: 'float',
},
latitude: {
type: 'float'
}
}
};
Warehouse.js
module.exports = {
identity: 'warehouse',
attributes: {
facility: {
columnName: 'id_facility',
model: 'facility',
},
name: {
type: 'string',
required: true
},
longitude: {
type: 'float',
},
latitude: {
type: 'float'
}
}
};
MainController's relevant code:
companies: function(req, res) {
company.find().populate('facilities').exec(function(err, comp){
var error = '';
if(err){
error = 'Unable to retrieve the requested information. Try again later and, if the problem persists, contact the platform administrator.';
} else if(!comp[0]) {
error = 'There\'s no company data inserted.';
}
// (...)
});
},
You should remove the references and on from your models.
Regarding nested population, just like I said in the comment, Waterline does not currently support it. You could check Waterline2 which, as they say, offers the possibility of nested populating, but is not recommended for production.
Otherwise you could check this out: Sails.js populate nested associations

Multiple hasMany associations within one model

I have the following JSON structure:
{
orderId : '00410',
name : 'Zuiger',
productionQuantity : '4',
materials : [
{
materialId : 'ALU.BALK.10X70',
description : 'Aluminium balk 10 x 70',
quantityPP : '70mm',
totalQuantity : '0.4'
},
{
materialId : 'ALU.BALK.10X70',
description : 'Aluminium balk 10 x 70',
quantityPP : '70mm',
totalQuantity : '0.4'
}],
operations : [
{
operationId : 'ZAGEN',
lineNr : '10',
description : 'Zagen groot',
started : false
},
{
operationId : 'FR003',
lineNr : '20',
description : 'Frezen Heidenhein',
started : true
}]
}
So i have an Order, which has a list of materials and/or a list of operations. This JSON is currently in a Store file using the Data tag and is autoLoaded. This is for testing purposes.
The model used for this is Order which contains 2 hasMany associations to material and operation:
Ext.define('wp-touch.model.Order', {
extend: 'Ext.data.Model',
requires: [
'wp-touch.model.Material',
'wp-touch.model.Operation'
],
config: {
idProperty: 'Id',
fields: [
{ name: 'orderId', type: 'string'},
{ name: 'name', type: 'string'},
{ name: 'productionQuantity', type: 'string'},
],
associations: [
{
type: 'hasMany',
associationKey: 'materials',
model: 'wp-touch.model.Material',
name: 'material',
primairyKey: 'materialId',
foreignKey: 'orderId'
},
{
type: 'hasMany',
associationKey: 'operations',
model: 'wp-touch.model.Operation',
name: 'operation',
primairyKey: 'operationId',
foreignKey: 'orderId'
}
],
}});
When the store is loaded it only loads the first hasMany. When i empty the materials array in the JSON message it loads in the operations just fine. So it seems it only loads one of the hasMany associations. Is there any way to fix this?
Here are the material and operation models;
Ext.define('wp-touch.model.Material', {
extend: 'Ext.data.Model',
config: {
idProperty: 'Id',
fields: [
{ name: 'materialId', type: 'string'},
{ name: 'description', type: 'string'},
{ name: 'quantityPP', type: 'string'},
{ name: 'totalQuantity',type: 'string'},
{ name: 'orderId', type: 'string'}
],
belongsTo: [
{
model: 'wp-touch.model.Order',
name: 'order',
primairyKey: 'materialId',
foreignKey: 'orderId'
}
]
}});
Ext.define('wp-touch.model.Operation', {
extend: 'Ext.data.Model',
config: {
idProperty: 'Id',
fields: [
{ name: 'operationId', type: 'string'},
{ name: 'lineNr', type: 'int'},
{ name: 'description', type: 'string'},
{ name: 'started', type: 'boolean'},
{ name: 'orderId', type: 'string'}
],
belongsTo: [
{
model: 'wp-touch.model.Order',
name: 'order',
primairyKey: 'operationId',
foreignKey: 'orderId'
}
]
}});

Binding json data into store ubsing extjs

i have json data like this
{"GetStudentDetails":
{"TotalCount":5,
"RootResults":[
{"city":"West Chester","country":"USA","state":"PA ","student_id":100},
{"city":"Philly","country":"USA","state":"PA","student_id":101},
{"city":"Buffalo","country":"USA","state":"NY","student_id":102},
{"city":"Naigra City","country":"USA","state":"NY","student_id":103},
{"city":"West Chester","country":"USA","state":"PA","student_id":104}]
}
}
How to get this data into a store?
i am trying using a model like this.
Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{ type: 'string', name: 'TotalCount' }
],
hasMany: [{ model: 'RootResults', name: 'RootResult'}]
});
Ext.define("RootResults", {
extend: 'Ext.data.Model',
fields: [
{ type: 'string', name: 'city' },
{ type: 'string', name: 'country' },
{ type: 'string', name: 'state' },
{ type: 'string', name: 'student_id' }
],
belongsTo: 'User'
});
var store = Ext.create('Ext.data.Store', {
model: 'User',
proxy: {
type: 'ajax',
url: 'users.json',
reader: {
type: 'json'
}
}
});
How should my model be? when i am giving some more simple json i am getting the store loaded. i think the problem is with mapping?
Define model as
Ext.define("RootResults", {
extend: 'Ext.data.Model',
fields: [
{ type: 'string', name: 'city' },
{ type: 'string', name: 'country' },
{ type: 'string', name: 'state' },
{ type: 'string', name: 'student_id' }
],
});
And inside the reader definition add two parameters:
root: 'GetStudentDetails.RootResults'
totalProperty: 'GetStudentDetails.TotalCount'
Something like that... Main idea - don't try to bring internal JSON structure to your model - it should be reader responsibility to properly parse it.