Can i pass data between two prompts in yeoman?
Eg i've got two prompts like
{
type: 'input',
name: 'Name',
message: 'Name?'
},{
type: 'input',
name: 'package',
message: 'Package?',
default: 'org.my.app.'+<prompt.name>
}
I want to show name property as default value for package? One way i can think of is:
Show a template in default (like in example)
Change the value later when creating the final template for user.
Another way that i tried is using when
{
type: 'input',
name: 'Name',
message: 'Name?'
},{
when: (response) => {
this.testValue = response.Name
return true
},
type: 'input',
name: 'package',
message: 'Package?',
default: 'org.my.app.'+this.testValue
}
but it gives undefined even though inside the function value has been stored for in this.testValue
Is there any better way?
i finally found the answer. The way to achieve it is using two prompt variables and running the second one after first's promise returns
const prompt1 = [{
type: 'input',
name: 'Name',
message: 'Name?'
}];
return this.prompt(prompt1).then(props => {
const prompt2 = [{
type: 'input',
name: 'package',
message: 'Package?',
default: 'org.my.app.'+props.name
}];
return this.prompt(prompt2).then(props => {
//code goes here
});
});
Related
I'm using Google's Model Viewer in my project, and unfortunately, it is treating certain events as non-interaction: false when they should be non-interaction: true. In my case, these are the events that fire when the model loads, when it detects a user with AR support, and when it detects a user with QR support.
How can I manually set the non-interaction values of these events to true? I've attempted solutions similar to this to no avail:
export type AnalyticsEvent = {
type: string;
category: string;
action: string;
label: string;
value: number;
nonInteraction: boolean;
};
export const USER_WITH_AR_SUPPORT_TEMPLATE: AnalyticsEvent = {
type: 'event',
category: AR_CATEGORY,
action: 'UserWithArSupport',
label: '',
value: '',
nonInteraction: true,
};
"kind": "javascript-module",
"path": "src/globals/ArEvents.ts",
"declarations": [
{
"kind": "variable",
"name": "userWithArSupportTemplate",
"type": {
"text": "AnalyticsEvent"
},
"default": "{\n type: 'event',\n category: ARCategory,\n action: 'UserWithArSupport',\n label: '',\n ,\n nonInteraction: true}"
},
I've also attempted the solution here, as well as several similar ones. Am I using the wrong variable name or index for non-interaction?
Added more code as requested
public sendGaEvent(uaCode: string, eventData: AnalyticsEvent, sku: string, log: boolean) {
...
const instance = this[$analyticsMap].get(uaCode);
const tracker = instance!.tracker;
if (!tracker) {
const queue = instance!.queue;
queue!.enqueue(eventData);
LoggerInstance.log({
sender: this,
message: 'Enqueuing GA event',
force: log
});
} else {
ga(`${tracker}.send`,
eventData.type,
eventData.category,
eventData.action,
eventData.label,
eventData.nonInteraction,
{
hitCallback: () => LoggerInstance.log({
sender: this,
message: 'GA event successfully sent!',
objectToLog: eventData,
force: log
})
}
);
LoggerInstance.log({
sender: this,
message: 'Sending GA event',
force: log
});
}
...
}
EDIT: Using #d-_-b's suggestion, I found the proper form of the solution to be passing in nonInteraction as an object as follows:
ga(
'send',
'event',
'AR_CATEGORY',
'UserWithArSupport',
'label',
{'nonInteraction': true}
);
It is evidently important to keep the quotes around the name 'nonInteraction' when passing it in as an object
For Universal Analytics, the nonInteraction property should be passed as an object (see docs):
ga('send', 'event', 'AR_CATEGORY', 'UserWithArSupport', 'label', {
nonInteraction: true
});
If you're using gtag.js, you need to add non_interaction: true as documented here
gtag('event', '<event-name>', {
'event_label': '',
'event_category': 'AR_CATEGORY',
'event_action': 'UserWithArSupport',
'non_interaction': true
});
I'm using read-excel-file library to load an excel file with the next structure,
The problem is when the code read this value,
The returned value is the next,
And here is my code,
let ExcelLoader = window.readXlsxFile;
let input = document.getElementById('input-file');
//Task Created by Responsible person Status Created on Closed on Deadline Tags
const schema = {
'Task': {
prop: 'task',
type: String
},
'Created by': {
prop: 'createdBy',
type: String
},
'Responsible person': {
prop: 'responsiblePerson',
type: String
},
'Status': {
prop: 'status',
type: String
},
'Created on': {
prop: 'createdOn',
type: String
},
'Closed on': {
prop: 'closedOn',
type: String
},
'Deadline': {
prop: 'deadline',
type: String
},
'Tags': {
prop: 'tags',
type: String
}
};
input.addEventListener('change', () => {
console.log('The Change listener actioned!');
ExcelLoader(input.files[0], { schema })
.then(({rows, errors}) => {
console.log(rows);
//console.log(errors);
})
});
I'm doing this little excersice client side and I was trying to test other types of values in the schema paramether also I was looking for a converter from decimal to date and decimal to datetime with no success,
Can anybody knows what's going on?
I'm open to use other client side libraries...
As Tim Williams says, in Excel Dates and Times are stored as numbers.
I am building a command line interface in node.js using library: inquirer.
based on my need I want to render prompt, confirmation text etc when user input's. example.
inquirer usage
var _questions = [{
'type': 'list',
'name': 'databasetype',
'message': 'Choose database :',
'choices': ['mongoDB', 'mysql [alpha]', 'firebase [alpha]', 'url [alpha]'],
'default': 'mongoDB'
}, {
'type': 'input',
'name': 'xfactor',
'message': 'X Factor [email, username etc..] :'
}]
// show question's.
Inquirer.prompt(_questions).then(async (__answers) => {
console.log(__answers)
})
what i want
if user chooses mongoDB than it should render another prompt asking
mongodb url
You can use the when question property, its value should be a function that returns a boolean; true for show question, false for don't show question
so using your example:
_questions = [{
type: 'list',
name: 'databasetype',
message: 'Choose database :',
choices: ['mongoDB', 'mysql [alpha]', 'firebase [alpha]', 'url [alpha]'],
default: 'mongoDB'
}, {
type: 'input',
name: 'url',
message: 'Enter the URL',
when: (answers) => answers.databasetype === 'mongoDB'
}]
see more examples here when usage examples
I am using https://github.com/evoluteur/structured-filter and http://www.jquery-bootgrid.com/ to create an advanced search through ajax/php.
Initially the code works and returns the data from the php file, but when trying to use structured-filter to pass $_GET variables to the php file through the use of jquery-bootgrid I am struggling.
No matter what I try, the url it is posting to has no $_GET variables, I have tried $("#grid-data").bootgrid("reload"); but nothing changes.
It appears the params variable is just not updating.
Here is my jquery script in full:
<script type="text/javascript">
$(document).ready(function() {
$("#myFilter").structFilter({
fields: [{
type: "text",
id: "gamertag",
label: "Gamertag"
}, {
type: "text",
id: "name",
label: "Team Name"
}, {
type: "number",
id: "wagePerMatch",
label: "Wage Per Match"
}, {
type: "number",
id: "gamesRemaining",
label: "Contract Games Remanining"
}, {
type: "boolean",
id: "transferListed",
label: "Transfer Listed"
}
]
});
var params = "";
$("#myFilter").on("change.search", function(event) {
var params = $("#myFilter").structFilter("valUrl");
$("#grid-data").bootgrid("reload");
console.log(params); // works, returns params
});
$("#grid-data").bootgrid({
ajax: true,
url: function() {
return "/api/search.php?" + params; // params never updates?
}
});
});
</script>
Is there a way to update params in .bootgrid when it changes in $("#myFilter").on("change.search" as right now its only sending requests to /api/search.php? (missing the parameters)
Now i don't have to much reputation, i am unable to add comment on this,
Please check this below URL, hope this will help you
http://www.jquery-bootgrid.com/Documentation#events
if you are looking for append the rows in existing grid so you can use "append" as given in URL or if you want to update the whole table you can destory the table and re-create a "bootgrid" object with binding with the respective DOM id's
How do you add a property to an entity dynamically? I've been looking, but haven't found anything.
For example, I have this model definition (I'm using the WebSQL provider):
$data.Entity.extend('$db.Types.Person', {
id: { type: 'int', key: true, computed: true },
name: { type: 'string' }
});
$data.EntityContext.extend('$db.Types.DBContext', {
Persons: { type: $data.EntitySet, elementType: $db.Types.Person},
});
At some point I need to extend my model with new properties. Initially I don't know these properties' names.
The syntax is very simple for this, but the background info is more important, please read the whole answer before you reuse the snippet.
The YourType can be extended with new fields using the YourType.addMember() function. See this example snippet:
$data.Entity.extend('Product', {
id: { type: 'int', key: true, computed: true },
Name: { type: 'string' }
});
$data.EntityContext.extend('Northwind', {
Products: { type: $data.EntitySet, elementType: Product},
});
Product.addMember('Description', {
type:'string',
key: false,
computed: false,
required: false
});
var context = new Northwind({provider: 'webSql', databaseName: 'Northwind'});
context.onReady(function() {
var product1 = new Product({ Name: 'Beer', Description: 'tasty'});
context.Products.add(product1);
context.saveChanges(function(result) {
//check the content of WebSQL DB
console.log(product1);
});
});
You can user the addMember() only before creating an instance of the context.
Important info:
There is no data migration/merge by in the library, and the default behavior on schema modification for webSql is to drop&re-create the DB. As IndexedDB isn't bound to a schema, the existing records won't be dropped. Make a try by running this code and adding more fields, here is a working JSFiddle.
The real solution is to use Schema Evolution module of JayData Pro to manage the changes in your data model.