clr-tree-node selection not effect collapsed child nodes - vmware-clarity

I've build a component based on Clarity (v 0.13.1) Tree view,
I have an issue when i am selecting\ unselecting a collapsed parent node,
it's not affecting child nodes selection,
and when i'm expanding him he is getting selected\unselected again.
Can someone assist please?
below is the view:
<clr-tree-node class="tree-root" [(clrSelected)]="tree.selected" id="statusTreeFilter">
{{tree.name}}
<ng-template [(clrIfExpanded)]="tree.expanded">
<clr-tree-node *ngFor="let group of tree.childs" [(clrSelected)]="group.selected">
<span>{{group.name}}</span>
<ng-template [(clrIfExpanded)]="group.expanded">
<clr-tree-node *ngFor="let status of group.childs" [(clrSelected)]="status.enable">
<span>{{status.name}}</span>
<ng-template></ng-template>
</clr-tree-node>
</ng-template>
</clr-tree-node>
</ng-template>
and Data:
let tree = {
"name": "All",
"selected": true,
"expanded": false,
"childs": [
{
"name": "Generate",
"selected": true,
"expanded": false,
"childs": [
{
"name": "Init",
"enable": true
},
{
"name": "Generating",
"enable": true
},
{
"name": "Generated",
"enable": true
}
]
},
{
"name": "Printing",
"selected": true,
"expanded": false,
"childs": [
{
"name": "Printing",
"enable": true
}
]
},
{
"name": "Finalized",
"selected": true,
"expanded": false,
"childs": [
{
"name": "Completed",
"enable": true
},
{
"name": "Cancelled",
"enable": true
}
]
}
]
}

Your root node needs to point to the boolean selected property of the selection object. You're setting the clrSelected binding to the whole object, which causes this behavior.
<clr-tree-node class="tree-root" [(clrSelected)]="selection.selected" id="statusTreeFilter">
Here it is setup fully. https://stackblitz.com/edit/clarity-hmrndh?file=app%2Fapp.component.html

Fixed on clarity 1.0 (breaking changes)
See ticket here

Related

Alexa APL. Problems getting AlexaHeader component to sit atop single Image component?

I want to have a header at the top of my Alexa Skill APL page that shows a Title and a Sub-Title. Directly below it, I want to have an image. In other words I want to have the Title and Sub-Title in a box that sits at the top of the image, occupying the top row of the screen.
The AlexaHeader component seems perfect for this. But when I use it in a container as the first child item, with the Image component next with its scale property set to best-fit, the Image component takes up the whole screen and the AlexaHeader component is behind the image, centered vertically and not at the top of the APL page. I can see it behind the image because the image does not fill the screen horizontally, only vertically.
How can I get the look I want?
Here is my APL JSON for the layout element I am working with:
"my-layout": {
"type": "Alexa.Presentation.APL.RenderDocument",
"token": "ABC_RENDERED_DOCUMENT",
"version": "1.0",
"document": {
"type": "APL",
"version": "1.0",
"import": [
{
"name": "alexa-layouts",
"version": "1.0.0"
}
],
"mainTemplate": {
"description": "********* Minimal APL document **********",
"parameters": [
"payload"
],
"items": [
{
"type": "Container",
"width": "100%",
"height": "100%",
"alignItems": "center",
"justifyContent": "center",
"items": [
{
"type": "AlexaHeader",
"headerBackButton": true,
"headerBackButtonAccessibilityLabel": "back",
"headerBackgroundColor": "orange",
"headerTitle": "${payload.visualProperties.title}",
"headerSubtitle":"${payload.visualProperties.subtitle}",
"headerAttributionText": "photos by Pexels.com",
"headerAttributionImage": "https://d2o906d8ln7ui1.cloudfront.net/images/cheeseskillicon.png",
"headerAttributionPrimacy": true,
"headerDivider": true
},
{
"type": "Image",
"source": "${payload.visualProperties.background}",
"position": "absolute",
"width": "100vw",
"height": "100vh",
"scale": "best-fit"
}
]
}
]
}
},
"datasources": {
"visualProperties": {
"background": "https://m.media-amazon.com/images/G/01/alexa-games/backgrounds/memorystory-gui-1._CB473869069_.png",
"title": "",
"subtitle": ""
}
}
}
Seems you have the absolute positioning set so that the image will go on top of your header (you just need to swap the order) as well as a few other items that needs tweaking.
I might misinterpreted your requirements but below is my best guess of what you want. Let me know if you want any tweaks.
"my-layout": {
"type": "Alexa.Presentation.APL.RenderDocument",
"token": "ABC_RENDERED_DOCUMENT",
"version": "1.0",
"document": {
"type": "APL",
"version": "1.0",
"import": [
{
"name": "alexa-layouts",
"version": "1.0.0"
}
],
"mainTemplate": {
"description": "********* Minimal APL document **********",
"parameters": [
"payload"
],
"items": [
{
"type": "Container",
"width": "100%",
"height": "100%",
"items": [
{
"type": "AlexaHeader",
"headerBackButton": true,
"headerBackButtonAccessibilityLabel": "back",
"headerBackgroundColor": "orange",
"headerTitle": "${payload.visualProperties.title}",
"headerSubtitle": "${payload.visualProperties.subtitle}",
"headerAttributionText": "photos by Pexels.com",
"headerAttributionImage": "https://d2o906d8ln7ui1.cloudfront.net/images/cheeseskillicon.png",
"headerAttributionPrimacy": true
},
{
"type": "Image",
"source": "${payload.visualProperties.background}",
"width": "100vw",
"height": "100vh",
"scale": "best-fit",
"align": "bottom"
}
]
}
]
}
},
"datasources": {
"visualProperties": {
"background": "https://m.media-amazon.com/images/G/01/alexa-games/backgrounds/memorystory-gui-1._CB473869069_.png",
"title": "Header",
"subtitle": "Header Subtitle"
}
}
}

Create product variations with python woocommerce api

I am attempting to create a product with variations in WooCommerce but I am getting this error:
{u'message': u'No route was found matching the URL and request method', u'code': u'rest_no_route', u'data': {u'status': 404}}
when I run the create_variation function from the API.
I ran a GET on the attributes for the product I created and it found no attributes even though the printed response when I created the product had the attributes listed.
Here is my code to create the variable product:
data = {
"name": row[3],
"type": "variable",
"description": row[4],
"images": [
{
"src": row[15],
"position": 0
}
],
"in_stock": True,
"sku": row[2],
'attributes': [
{
'name': 'Size',
'variation': True,
'visible': True,
'options': sizeList,
},
{
'name': 'Color',
'variation': True,
'visible': True,
'options': colorList,
}
],
}
print(wcapiNew.post("products", data).json())
Here is my code to create the variations:
result = wcapi.get("products/sku/"+row[2]).json()
product_id = result['product']['id']
variationData = {
"regular_price": row[17],
"image": {
"src": row[13]
},
"sku": row[19],
"attributes": [
{
"name": "Color",
"option": row[6]
},
{
"name": "Size",
"option": row[10]
}
]
}
print(wcapiNew.post("products/"+str(product_id)+"/variations", variationData).json())
I've been tearing my hair out trying to figure out what I'm doing wrong but I'm clueless right now.
Any help is appreciated. Thanks.
This is my variations data, and it work.
data_1 = {
"regular_price": "9.00",
"sku": "premium-quality-101-red",
"attributes": [
{
"id": 1,
"option": "Red"
}]
}
I figure out that you need to use id, and update one variation at a time.

Watson Assistant (Conversation) service behaves differently when created via API versus created in the Browser

We are seeing different behaviour when we create a workspace in the WebInterface versus when we create the same conversation via the API.
The JSON export for the dialognode is the same:
{ "type": "standard",
"title": "SmallTalk: weerbericht",
"output": {
"text": {
"values": [],
"selection_policy": "sequential" } },
"parent": "smalltalk_container",
"context": { "user_weer": "#weerbericht",
"user_location": "#plaatsnamen" },
"metadata": {
"_customization": {
"mcr": false } },
"next_step": { "behavior": "jump_to", "selector": "condition", "dialog_node": "node_33_1519129633532"
},
"conditions": "#ST_weersbericht",
"description": null,
"dialog_node": "node_9_1517408489377",
"previous_sibling": "node_3_1518680265483" },
But the behaviour is different, which can be explained when we look at the UI
there is a difference
This is the UI for the dialogNode created via the browser
This is the UI for the same dialogNode created via the API
One difference we found is the Multiple Reponse switch:
It should be OFF (image on the right) and as per the JSON (mcr:false).
But even when we switch it on manually, the context variables don't show.
What should I be looking for in the API to fix this ?
The dialog model for multiple condition responses is that the parent node needs to be either standard dialog node or frame. Now when adding a multiple condition response to this node (and hence making an MCR node out of that parent node) you need to add a dialog node with "type":"response_condition" under this node.
This is a way how to create multiple condition responses through the api.
To give you and example to create MCR node:
The JSON of dialog nodes that need to pushed through the API will look like:
{
"type": "standard",
"title": "mcr node",
"output": {
},
"parent": null,
"context": null,
"metadata": {
"_customization": {
"mcr": true
}
},
"next_step": null,
"conditions": "#book_flight",
"digress_in": "does_not_return",
"description": null,
"dialog_node": "node_8_1525086089064",
"digress_out": "allow_all",
"previous_sibling": null
},
{
"type": "response_condition",
"title": null,
"output": {
"text": {
"values": ["I see city entity!"]
}
},
"parent": "node_8_1525086089064",
"context": null,
"metadata": {
},
"next_step": null,
"conditions": "#city",
"description": null,
"dialog_node": "node_9_1525086100114",
"previous_sibling": null
},
{
"type": "response_condition",
"title": null,
"output": {
"text": {
"values": ["I don't see anything."]
}
},
"parent": "node_8_1525086089064",
"context": null,
"metadata": {
},
"next_step": null,
"conditions": "anything_else",
"description": null,
"dialog_node": "node_10_1525086122332",
"previous_sibling": "node_9_1525086100114"
}

How do you query data by with multiple conditions or indexes?

I'm trying to design a performant NoSQL schema for my Firebase application, but how would I query multiple checkpoints which have a unique tag?
Consider the following rules:
Tiers can have multiple tags
Tags can have multiple Checkpoints
Tag keys (names) are unique for each tier
Checkpoints can have multiple tags, but only 1 tag per tier
Here's what I have so far:
{
"tiers": {
"1": {
"web": true,
"android": true
},
"2": {
"basics": true,
"angular2": true,
"aurelia": true
},
"3": {
"basics": true,
"components": true
}
},
"tags" : {
"1": {
"web": {
"name": "Web Development",
"children": {
"front-end": true,
"angular2": true,
"aurelia": true
}
},
"android": {
"name": "Android Development",
"children": {
"front-end": true
}
}
},
"2": {
"front-end": {
"name": "Basics",
"parents": {
"web": true,
"android": true
},
"children": {
"angular2": true,
"aurelia": true,
"android-studio": true
}
}
},
"3": {
"angular2": {
"name": "Angular 2.x",
"parents": {...},
"children": {...}
},
"aurelia": {
"name": "Aurelia 1.x"
}
}
},
"checkpoints": {
"<randomKey>" : {
"name": "Angular 2 Quick Start",
"tags": {
"1": "web",
"2": "front-end",
"3": "angular2"
}
}
}
}
Right now I can query for all checkpoints under the Tier 1 web tag with:
ref.orderByChild('tags/1').equalTo("web").once('value', snap => console.log(snap.val()));
but since you can only define one indexOn rule, it's not optimized. At least if I can set the indexOn rule I can at least filter out most of the checkpoints then filter the rest in my code.
What can I do to efficiently query my checkpoints based on multiple tags AND the tiers?
Eventually I'd need to do a query for checkpoints with "tags": {"1": "web" AND "2": "front-end"} which I can't for the life of me figure out how to execute efficiently. I was thinking of doing another table with composite keys (e.g. each tier/tag contains references to ALL child checkpoints), but that would lead to requiring me to add and delete references within each tier.
There must be a better way.
I was vastly over complicating the solution - I ended up:
Removing Tier from the equation all together
Adding each checkpoint within each tag it was related to
Querying all checkpoints related to each selected tag and removing the ones which did not appear in each tag selected
Here's my new schema:
allTags = [
{"abc": true, "def": true, "hij": true},
{"abc": true, "def": true}
];
tags: [
{ "0": [
{"software-development": {name: "Software Development", checkpoints: [ {"abc": true}, {"def": true}, {"hij": true}]}}
]},
{"1": [
{"web": {name: "Web", checkpoints: [ {"abc": true}, {"def": true}]}},
{"android": {name: "Android", checkpoints: [{"hij": true}]}}
]}
];
checkpoints: [
{"abc": { name: "Angular2 Quick Start"}},
{"def": { name: "Building global directives in Angular2"}},
{"hij": { name: "Android Quick Start"}},
];
Creating a new Checkpoint:
public createCheckpoint(tags: any[], checkpoint: any) {
// push checkpoint
let checkpointRef = this.firebase.child('test/checkpoints');
let checkpointKey = checkpointRef.push(checkpoint).key(); // might have to do separate call
// Add checkpoint under each related tag
tags.forEach(tag => {
let tagRef = this.firebase.child('test/tags/' + tag.tier + '/' + tag.key + '/checkpoints/' + checkpointKey);
tagRef.set(true)
});
}
Retrieving all checkpoints based on selected tags:
public getCheckpointss(tags: any[]) {
// tag.tier, tag.key
let checkpointKeysToGet: string[] = [];
tags.forEach(tag => {
let ref = this.firebase.child('test/tags/' + tag.tier + '/' + tag.key + '/checkpoints');
ref.once('value', snap => {
let tagKeys:string[] = this.convertToArray(snap.val());
if (checkpointKeysToGet.length == 0){
checkpointKeysToGet = checkpointKeysToGet.concat(tagKeys);
}
else {
checkpointKeysToGet.forEach(existingTagKey => {
let tagKeysInBothTiers = tagKeys.filter(tagKey => {
return checkpointKeysToGet.includes(tagKey, 0)
});
checkpointKeysToGet = tagKeysInBothTiers;
console.log(checkpointKeysToGet);
});
}
});
});
}
All valid criticisms are welcome as long as you propose a solution to go along with it :)

CSS Lint ignore all IE6 and IE7 based errors

I'm using Sublime Text 3, and CSS Linter.
In my settings I've put the ignore rule, and currently there is only the "outline-none" rule, I'd like to include all the rules which refer to IE6 and IE7 based errors.
Is there a list what are the IE6 and IE7 rules so that I can put them in the ignore array?
My CSSLint.sublime-settings look like this:
// CSSLint rules you wish to ignore. Must be an array. Leave blank to include all default rules.
{
"ignore": ["outline-none"]
}
To answer my own question, in the end I figured how to do what I need:
{
"user": {
"debug": false,
"delay": 0.25,
"error_color": "D02000",
"gutter_theme": "Packages/SublimeLinter/gutter-themes/Danish Royalty/Danish Royalty.gutter-theme",
"gutter_theme_excludes": [],
"lint_mode": "background",
"linters": {
"csslint": {
"#disable": false,
"args": [],
"box-sizing": false,
"errors": "",
"excludes": [],
"ignore": [
"outline-none",
"box-sizing",
"ids",
"adjoining-classes",
"floats",
"qualified-headings",
"unique-headings",
"important",
"universal-selector",
"box-model",
"font-faces",
"font-sizes"
],
"warnings": ""
},
"eslint": {
"#disable": true,
"args": [],
"excludes": []
},
"jscs": {
"#disable": true,
"args": [],
"excludes": []
},
"jshint": {
"#disable": false,
"args": [],
"excludes": [],
"ignore": [
"newcap"
],
"newcap": false,
"tab_size": 4
},
"jslint": {
"#disable": true,
"args": [],
"excludes": [],
"ignore": [
"newcap"
],
"newcap": false
},
"php": {
"#disable": false,
"args": [],
"excludes": []
}
},
"mark_style": "outline",
"no_column_highlights_line": false,
"passive_warnings": false,
"paths": {
"linux": [],
"osx": [],
"windows": []
},
"python_paths": {
"linux": [],
"osx": [],
"windows": []
},
"rc_search_limit": 3,
"shell_timeout": 10,
"show_errors_on_save": false,
"show_marks_in_minimap": true,
"syntax_map": {
"html (django)": "html",
"html (rails)": "html",
"html 5": "html",
"php": "html",
"python django": "python"
},
"warning_color": "D02000",
"wrap_find": true
}
}
Just go to Preferences > Package Settings > SublimeLinter > Settings - User and paste the above in the opened file.
These are the options that I found not to be of practical importance, so I just ignored them.
Hope it helps :)

Resources