I'm developing a web app, and have a sample data that looks like this as a ts file:
/** Example file/folder data. */
export const files = [
{
name: 'privatec-omponents',
type: 'folder',
date: '11/21/2020',
kind: 'folder',
size: '--',
children: [
{
name: 'private-src',
type: 'folder',
date: '11/21/2020',
kind: 'folder',
size: '--',
children: [
{
name: 'private-cdk',
type: 'folder',
date: '11/21/2020',
kind: 'folder',
size: '--',
children: [
{ name: 'private-package.json', type: 'file', date:'11/21/2020',kind: 'json', size: '2MB' },
{ name: 'private-BUILD.bazel', type: 'file', date: '11/21/2020', kind: 'bazel', size: '2MB' },
]
},
{ name: 'private-material', type: 'folder', date: '11/21/2020', kind: 'folder', size: '--' }
]
}
]
},
{
name: 'private-angular',
type: 'folder',
date: '11/21/2020',
kind: 'folder',
size: '--',
children: [
{
name: 'private-packages',
type: 'folder',
date: '11/21/2020',
kind: 'folder',
size: '--',
children: [
{ name: 'private-travis.yml', type: 'file', date: '11/21/2020', kind: 'yml', size: '2MB' },
{ name: 'firebase.json', type: 'file', date: '11/21/2020', kind: 'json', size: '2MB' }
]
},
{ name: 'private-package.json', type: 'file', date: '11/21/2020', kind: 'json', size: '--' }
]
}
];
I want to show all folder names as "mat-select" to let users choose the file directory to save their files, however, currently, only parent folders are displayed.
Is there any way that I can display all folders in the "mat-option"? I also want to add padding if the folder has a parent folder?
This is how HTML looks like.
<mat-form-field>
<mat-label>Drirectry Name</mat-label>
<mat-select name="fileName" [(value)]="selectedCountry" placeholder="Country">
<mat-option *ngFor="let file of file" [value]="file.name">
{{file.name}}
</mat-option>
</mat-select>
</mat-form-field>
This is how it appears on the web.
How can I do them?
You actually want to wrap your mat-option in a mat-optgroup for any nested values
Example:
<mat-select [formControl]="pokemonControl">
<mat-option>-- None --</mat-option>
<mat-optgroup *ngFor="let group of pokemonGroups" [label]="group.name"
[disabled]="group.disabled">
<mat-option *ngFor="let pokemon of group.pokemon" [value]="pokemon.value">
{{pokemon.viewValue}}
</mat-option>
</mat-optgroup>
</mat-select>
See Select with option groups in the docs: https://material.angular.io/components/select/examples
Related
I have a very large json file with an error that I need to fix.
{
id: 1,
name: 'Human',
type: {
id: { <==== here
id: 2,
name: 'Body',
image: 'body.png',
}, <==== here
},
},
I need to remove this id: { and the closing brace } lines inside type. How to remove them to make the object look like this?
{
id: 1,
name: 'Human',
type: {
id: 1,
name: 'Body',
image: 'body.png',
},
},
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?
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.
Here is my code:
var playerInstance = jwplayer("mySingleVideoWrapper").setup({
image: getCurrentPosterSrc,
sources: [
{
file: 'file-360.mp4',
label: "360p"
},{
file: 'file-480.mp4',
label: "480p"
},{
file: 'file-720.mp4',
label: "720p HD"
},{
file: 'file-1080.mp4',
label: "1080p HD"
}
],
width: "100%",
androidhls: 'true',
type: "hls",
fallback:true,
aspectratio: "16:9",
autostart: true,
logo: {
hide: true
},
tracks: [{
file: "/assets/captions-en.vtt",
label: "EN",
kind: "captions",
"default": true
},{
file: "/assets/captions-es.vtt",
label: "ES",
kind: "captions"
},{
file: "/assets/captions-fr.vtt",
kind: "captions",
label: "FR"
},{
file: "js/assets/captions-de.vtt",
label: "DE",
kind: "captions"
}]
});
And also here is a screenshot where I highlighted what I need
So I need that 'Auto' button which will autodetect which is the best quality for current user. Now with my code I see all 4 sources/qualities but 'Auto' button can't see. How can I add it ?
Amazon Support have me this useful article link http://www.jwplayer.com/blog/encoding-hls-with-amazon-elastic-transcoder/ and I could do what I want.
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'
}
]
}});