Plop doesnt generate my component because replace is undefined - replace

I struggle with this problem and I don't know why the cmd say that replace is undefined.
I researched a bit but couldn't find any reason why the script should fail. I console.log the whole flow of the code but everything gets passed.
I am currently really speechless and trying to avoid but I just can't continue.
plopfile.js
const componentPlop = require('./controllers/component/component.plopfile');
module.exports = (plop) => {
plop.setWelcomeMessage('Generators');
componentPlop(plop);
};
component.plopfile.js
const componentPlop = (plop) => {
plop.setGenerator('📦 Components', {
description:
'This area is responsible for creating, editing and managing 📦 Components',
prompts: [
{
name: 'componentName',
type: 'input',
message: 'Component name: ',
},
{
name: 'componentType',
type: 'list',
message: 'Component type: ',
choices: [
'animations',
'atoms',
'molecules',
'organismns',
'templates',
'layouts',
],
},
{
type: 'list',
name: 'componentTemplate',
message: 'Component Template',
default: 'none',
choices: [
{ name: 'Default', value: 'props' },
{ name: 'With Variants', value: 'variants' },
],
},
],
actions: (data) => {
let actions = [
{
type: 'add',
path: '../src/components/{{pascalCase name}}/index.ts',
templateFile: 'templates/ComponentIndex.ts.hbs',
},
{
type: 'add',
path: '../src/components/{{pascalCase name}}/{{pascalCase name}}.test.tsx',
templateFile: 'templates/test.ts.hbs',
},
];
if (data.componentTemplate === 'props') {
actions = actions.concat([
{
type: 'add',
path: '../src/components/{{pascalCase name}}/{{pascalCase name}}.tsx',
templateFile: 'templates/Component.ts.hbs',
},
{
type: 'add',
path: '../src/components/{{pascalCase name}}/{{pascalCase name}}.stories.tsx',
templateFile: 'templates/storiesWithProps.ts.hbs',
},
]);
}
if (data.componentTemplate === 'variants') {
actions = actions.concat([
{
type: 'add',
path: '../src/components/{{pascalCase name}}/{{pascalCase name}}.tsx',
templateFile: 'templates/ComponentWithVariants.ts.hbs',
},
{
type: 'add',
path: '../src/components/{{pascalCase name}}/{{pascalCase name}}.stories.tsx',
templateFile: 'templates/storiesWithVariants.ts.hbs',
},
]);
}
return actions;
},
});
};
module.exports = componentPlop;
Even in the first action does fail I showcase the first action template
Component.ts.hbs
import { FC } from 'react';
import tw, { styled, css, theme } from 'twin.macro';
export interface {{pascalCase name}}Props {
children: React.ReactNode;
}
const Styled{{pascalCase name}} = styled.div`
${tw` `}
`;
export const {{pascalCase name}}: FC<{{pascalCase name}}Props> = ({ children }) => {
return <Styled{{pascalCase name}}>{children}</Styled>;
};
The Error
✖ ++ Cannot read property 'replace' of undefined
✖ ++ ../src/components/{{pascalCase name}}/{{pascalCase name}}.test.tsx Aborted due to previous action failure
✖ ++ ../src/components/{{pascalCase name}}/{{pascalCase name}}.tsx Aborted due to previous action failure
✖ ++ ../src/components/{{pascalCase name}}/{{pascalCase name}}.stories.tsx Aborted due to previous action failure
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Best Regards
Knome

To achieve the processing you expect, use {{pascalCase componentName}} instead of {{camelCase name}}
write the value of the name option directly.
I'm sorry for my poor English.

Related

context body not working in loopback

guys, I m new to loopback, can anybody tell me what I m doing wrong below is my code
Permissiontb.assembleAndInsert = async (ctx, cb) => {
console.log(ctx.args.data)
console.log(ctx.res.body)
};
Permissiontb.remoteMethod('assembleAndInsert', {
http: {
path: '/assembleAndInsert',
verb: 'post',
},
accepts: [{ arg: 'data', type: 'object', http: { source: 'context' } },
{"arg": "options", "type": "object", "http": "optionsFromRequest"}],
returns: {
arg: 'data',
type: 'object',
},
});
now my problem is that if i does console.log(ctx.res.body) i got null can anybody tell me what i m doing wrong
Please refer Link
You can use ctx.req.body
FYI : You can log ctx.req and see all the available data in it.

Loopback remote method not returning response body

So I created this remote method in loopback:
Message.findUserMessages = function(id,cb) {
Message.find({
where: {
from_user_id: id
},
include: {
"relation":"message_text"
}
});
};
Message.remoteMethod('findUserMessages', {
accepts: {
arg: 'id',
type: 'number'
},
returns: {
arg: 'response',
type: 'Object'
},
http: {
path: '/user/',
verb: 'get'
}
});
But when I view the response, it does not show the output in the response body. The only reason I know the correct results are being accessed is due to the fact that my DB is returning the result of the query. How do I get put the output of the query in the response body?
The correct code should be:
Message.findUserMessages = function(id, cb) {
Message.find({
where: {
from_user_id: id
},
include: {
"relation":"message_text"
}
}, function(err, response) {
if (err) throw err;
cb(null, response);
});
};
Message.remoteMethod('findUserMessages', {
accepts: {
arg: 'id',
type: 'number',
required: true,
http: { source: 'path' }
},
returns: {
arg: 'response',
type: 'Object',
root: true
},
http: {
path: '/user/:id/findUserMessages',
verb: 'get'
}
});
You forget to callback the response.
Note: I've also changed the http url path hoping you wanted it like so. And also source to the argument is set to path. You might also want to look at usage of root.

Implementing Batch Update in Kendo UI GRID not work

While trying to perform batch update, I am not able to post values to MVC WEB API controller neither I am getting Record IDs in mu PUT controller.
I have already visited some of the links egarding same problem but got no solution.
$(document).ready(function () {
debugger;
var webapiUrl = (My webapi);
dataSource = new kendo.data.DataSource({
type: "json",
transport: {
read: {
url: webapiUrl + api/GetProductsByShipID/1",
contentType: "application/json",
},
update: {
url: webapiUrl + api/OpportunityProducts/1",
contentType: "application/json",
type: "PUT"
},
destroy: {
url: webapiUrl + /api/OpportunityProducts/",
contentType: "application/json",
type: "DELETE"
},
create: {
url: webapiUrl + /api/OpportunityProducts/",
contentType: "application/json",
type: "POST"
},
parameterMap: function (options, operation) {
if (operation !== "read") {
return options;
}
}
},
batch: true,
pageSize: 10,
schema: {
model: {
id: "ID",
fields: {
ID: { editable: false, nullable: true },
ProductDesc: { type: "string" },
Quantity: {type: "number"},
UnitPrice: { type: "number"}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
navigatable: true,
pageable: true,
toolbar: ["create", "save", "cancel"],
columns: [
"ProductName",
{ field: "ProductDesc", title: "Product Desc"},
{ field: "Quantity", title: "Quantity" },
{ field: "UnitPrice", width: 120 },
{ command: "destroy", title: " ", width:150 }],
editable: true
});
});
</script>
Well after some workaround, late night I was able to modify parameterMap section of my kendo grid which lead me to expected output.
This is how I updated my parameterMap section...
Previous
parameterMap: function (options, operation) {
if (operation !== "read") {
return options;
}
}
Updated
parameterMap: function (options, operation) {
debugger;
if (operation !== "read" && options.models) {
var webapiUrl = (my webapi);
var i = 0;
for (i = 0; i < options.models.length; i++) {
$.ajax({
cache: false,
async: true,
type: "PUT",
url: webapiUrl + "/api/OpportunityProducts/" + options.models[i].Id,
data: {
ID: options.models[i].ID,
ProductDesc: options.models[i].ProductDesc,
Quantity: options.models[i].Quantity
},
success: function (data) {
},
error: function (jqXHR, exception) {
alert(exception);
}
});
}

ExtJS 4.1.0 proxy returns update api instead of create

I was working on a code which was about integrating ExtJS 4 and Django. The link is:
https://github.com/diegocmsantos/extjs4-tdc2011-django
It works fine on ExtJS 4.0.0. But when I upgrade to 4.1.0 it's proxy returns update api instead of create.
I have added the 'idProperty' parameter to the Model, but still gives me the same result.
Model class:
Ext.define('TDC2011.model.Contact', {
extend: 'Ext.data.Model',
idProperty: 'id',
fields : [
{ name : "id", type : "int", mapping : "#id" },
{ name : "name", type : "string"},
{ name : "phone", type : "string"},
{ name : "email", type : "string"}]
});
Store Class:
Ext.define('TDC2011.store.Contacts', {
extend: 'Ext.data.Store',
model: 'TDC2011.model.Contact',
autoLoad: true,
pageSize: 35,
autoLoad: {start: 0, limit: 35},
proxy: {
type: 'ajax',
api: {
read : 'contact/view.action',
create : 'contact/create.action/',
update: 'contact/update.action/',
destroy: 'contact/delete.action/'
},
reader: {
type: 'json',
root: 'data',
successProperty: 'success'
},
writer: {
type: 'json',
writeAllFields: true,
encode: false,
root: 'data'
},
listeners: {
exception: function(proxy, response, operation){
Ext.MessageBox.show({
title: 'REMOTE EXCEPTION',
msg: operation.getError(),
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
}
}
}
});
Is there anyone who knows the main cause of problem?

Sencha Touch + PhoneGap - List not scrolling

I'm building an app and i've got a list loaded with some info from store, it has a lot of items in it but when I try to scroll down it scrolls back up as if there were not enough items to scroll. Here is some code:
app.views.SearchTab = Ext.extend(Ext.Panel, {
iconCls: 'search',
id: 'search',
items: {
xtype: 'list',
store: app.stores.results,
scroll: 'vertical',
itemTpl: '<div class="list_left_panel"><div class="list_photo_wrapper"><div class="list_photo"><img src="http://realio.cz/images/{link}_0s.jpg" /></div></div></div><div class="list_right_panel"><div class="list_name">{titul}</div><div class="list_info"><div>{cena} Kč</div><div class="list_info_grey">{m2} m<sup>2</sup></div><div>{typ}</div></div></div>',
onItemDisclosure: function (record) {
Ext.dispatch({
controller: app.controllers.detail,
action: 'show',
id: record.getId()
});
}
},
initComponent: function() {
app.stores.results.load();
app.views.SearchTab.superclass.initComponent.apply(this, arguments);
}
});
app.models.Results = Ext.regModel("app.models.Results", {
fields: [
{name: "titul", type: "string"},
{name: "book_id", type: "int"},
...
{name: "u", type: "int"}
]
});
app.stores.results = new Ext.data.Store({
model: "app.models.Results",
proxy: {
type: 'ajax',
url: 'http://site.com/json_list2.php?...',
reader: {
type: 'json',
root: 'markers'
}
},
autoLoad: false
});
How can i fix the list so that it scrolls correctly? Thanks.
add this library this will help you: https://github.com/Lioarlan/UxBufList-Sench-Touch-Extension