Nativescript RadDataForm MultilineText not working on Android - nativescript

I am using RadDataForm in my Nativescript Angular project and when I try to use "MultilineText" it doesn't work on Android, it just appears as a normal "Text" box. I am not able to enter multiple lines. Works fine on iOS.
add-store.model.ts
export class AddStore {
public name: string;
public description: string;
constructor(name: string, description: string,) {
this.name = name;
this.description = description;
}
}
add-store-metadata-validation.json
{
"isReadOnly": false,
"commitMode": "immediate",
"validationMode": "immediate",
"propertyAnnotations":
[
{
"name": "name",
"displayName": "Store Name",
"index": 1,
"editor": "Text"
},
{
"name": "description",
"displayName": "Description",
"index": 2,
"editor": "MultilineText"
}
]
}
add-store.component.ts
import { Component, AfterViewInit } from "#angular/core";
import { RouterExtensions } from "nativescript-angular/router";
import { UtilitiesService } from "~/services/utils.service";
import { AddStore } from "./add-store.model";
#Component({
selector: "add-store",
moduleId: module.id,
templateUrl: "./add-store.component.html"
})
export class AddStoreComponent implements AfterViewInit {
store: AddStore;
metadata;
constructor(private router:RouterExtensions) {
this.store = new AddStore("test name" , "test\nsdfgfsdf");
this.metadata = require("./add-store-metadata-validation.json");
}
ngAfterViewInit(): void {
}
goBack() {
this.router.back();
}
}
add-store.component.html
<ActionBar class="action-bar" title="Store Setup">
<NavigationButton android.systemIcon="ic_menu_back" (tap)="goBack()"></NavigationButton>
</ActionBar>
<GridLayout rows="*">
<StackLayout row="0" class="page page-content" height="100%">
<RadDataForm [source]="store" [metadata]="metadata"></RadDataForm>
</StackLayout>
</GridLayout>

It looks like a issue with plugin, you may report same in the feedback repo.
As a workaround you may use TKPropertyEditor directive and define the editor type.

Related

Can't display images sourced from GraphQL, error [gatsby-plugin-image] missing image prop

I'm trying to source content with images from Contentful into Gatsby but I failed to get images displayed.
I installed gatsby-transformer-sharp, gatsby-plugin-image, gatsby-plugin-sharp, gatsby-remark-images and gatsby-remark-images-contentful.
down below is a simple of my code
import { GatsbyImage, getImage } from "gatsby-plugin-image"
const Projects = ({ data }) => {
const projects = data.projects.nodes
return (
<Layout>
<Seo
title={"Projects"}
description={"Projects & Websites I've Developed"}
/>
<div className={styles.portfolio}>
<h1>My Portfolio</h1>
<h2>Projects & Websites I've Developed</h2>
<div className={styles.projects}>
{projects.map(project => (
<Link
to={"/projects/" + project.slug}
key={project.id}
className={styles.project}
>
<GatsbyImage
image={getImage(project.thumb)}
alt={project.title}
/>
<div className={styles.cardText}>
<h3>{project.title}</h3>
<p>{project.stack}</p>
</div>
</Link>
))}
</div>
</div>
</Layout>
)
}
export default Projects
export const query = graphql`
query ProjectsPage {
projects: allContentfulProjects(sort: { fields: date, order: DESC }) {
nodes {
key
slug
stack
title
thumb {
gatsbyImageData(placeholder: BLURRED, layout: FULL_WIDTH)
}
id
}
}
}
`
here what i got from GraphQL
{
"data": {
"projects": {
"nodes": [
{
"key": "project",
"slug": "portfolio-website",
"stack": "html - css - javascript",
"title": "Portfolio Website",
"thumb": [
{
"gatsbyImageData": {
"images": {
"sources": [
{
"srcSet": "https://images.ctfassets.net/kj59ethbquzj/1qDaw8RjPxxhzjOehxHz1g/152307656408e0efcf7c907a59cd91a7/personal-portfolio-website.png?w=750&h=361&q=50&fm=webp 750w,\nhttps://images.ctfassets.net/kj59ethbquzj/1qDaw8RjPxxhzjOehxHz1g/152307656408e0efcf7c907a59cd91a7/personal-portfolio-website.png?w=1080&h=520&q=50&fm=webp 1080w,\nhttps://images.ctfassets.net/kj59ethbquzj/1qDaw8RjPxxhzjOehxHz1g/152307656408e0efcf7c907a59cd91a7/personal-portfolio-website.png?w=1366&h=658&q=50&fm=webp 1366w,\nhttps://images.ctfassets.net/kj59ethbquzj/1qDaw8RjPxxhzjOehxHz1g/152307656408e0efcf7c907a59cd91a7/personal-portfolio-website.png?w=1920&h=925&q=50&fm=webp 1920w",
"sizes": "100vw",
"type": "image/webp"
}
],
"fallback": {
"src": "https://images.ctfassets.net/kj59ethbquzj/1qDaw8RjPxxhzjOehxHz1g/152307656408e0efcf7c907a59cd91a7/personal-portfolio-website.png?w=1920&h=925&q=50&fm=png",
"srcSet": "https://images.ctfassets.net/kj59ethbquzj/1qDaw8RjPxxhzjOehxHz1g/152307656408e0efcf7c907a59cd91a7/personal-portfolio-website.png?w=750&h=361&q=50&fm=png 750w,\nhttps://images.ctfassets.net/kj59ethbquzj/1qDaw8RjPxxhzjOehxHz1g/152307656408e0efcf7c907a59cd91a7/personal-portfolio-website.png?w=1080&h=520&q=50&fm=png 1080w,\nhttps://images.ctfassets.net/kj59ethbquzj/1qDaw8RjPxxhzjOehxHz1g/152307656408e0efcf7c907a59cd91a7/personal-portfolio-website.png?w=1366&h=658&q=50&fm=png 1366w,\nhttps://images.ctfassets.net/kj59ethbquzj/1qDaw8RjPxxhzjOehxHz1g/152307656408e0efcf7c907a59cd91a7/personal-portfolio-website.png?w=1920&h=925&q=50&fm=png 1920w",
"sizes": "100vw"
}
},
"layout": "fullWidth",
"width": 1,
"height": 0.4817708333333333,
"placeholder": {
"fallback": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAMAAACDi47UAAABv1BMVEUaGhosLSN+gm9ORjIcHBwlJB8kJBgkJBclJBgeHRREORVFWEeEj5SNingqNys+x8tWzNFk1Nhq1dl42Nx51dp219xw19twxMhjyMxKys89x8wnZlw7MhUiIRtrKiRCLCBHys5bztJu1tuD2t501tp62N1519yokpF3b25My9A/yc4oZ10VFRUkJCQoKChHR0c1NTUqKSotOCxEw8dbxcllys1owcR30dR2z9Nyz9NkyM2+n52cjo0/wsc5vsMrXVNdTx2niSCnjCqniiOfgyAtOC1HsbVRq69errJcpah1y8982N1u1dpto7F7RlG7lpeLWXVFr7koYFYtKiJJQyxTTDZMRS9DPSssNytNk5VWf3VbfWVWdVlnsKxryc1ays+xJ06sCy2sCS2wCi2bJkYrXlUjIyMuLi48PDw0NDQsLCwrNyw6n6I/j5BJlZBJlJFavL5Xxco4v8XDEz+QCiSqCSuHCiCJDidhKS07OzszMzMeHRk4NSg7OCs5NSk5NSg6Nio5Nik7Nys6NyocGhI6OjkxMTEYGBgmJiUmJiYjJCQlJSUXFxcWFhYRERE0Lhw7NBxBORwpJRswMDA0NTUvbwraAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAB3RJTUUH5gUJBR4Qdhx/lQAAAGRJREFUCNeNzUEKglAAANEZ/5cgRLTO0ZWCTtS6jdfxEJ5BUNyF+FuIiNSit5zNiKuUAbBAMHLWqfQgctGJWsdqrze/9PH6Z+R3hNphe8z5HFIgQuFQqHbtHSVlyFN9n3w92DQfWKcTSK8wndgAAAAASUVORK5CYII="
what it might be wrong with My code? need some help :)
According to what you said in the comment section, I'd say that there's a position in projects that has no thumbnail defined (or not properly queried).
Try adding a condition wrapping the GatsbyImage display:
{project.thumb && <GatsbyImage
image={getImage(project.thumb)}
alt={project.title}
/>}
That said, check in which project you have no thumbnail.
Finally I have figured it out by
1- I removed all My content and images in Contentful CMS and create a fresh ones, It seemed there was a bug with sourcing Images into GraphQL where the Image src was always giving an empty array!!
2- Taking out getImage function and replace it with <GatsbyImage image={project.thumb.gatsbyImageData} alt={project.title}/>
,then gatsby clean to clear the .cashe and also triggered clean cashe and rebuild.
Now everything is works well.

How to bind nested list item in collectionview in xamarin

I am new in xamarin. I am getting difficulty to bind my List in xamarin CollectionView.
I get the bellow json from API
{
"OK": 200,
"status": "success",
"data": [
{
"Category": "Category 1",
"List": [
{
"SubItem": "The A1"
},
{
"SubItem": "The A2"
}
]
},
{
"Category": "Category 2",
"List": [
{
"SubItem": "The C1 sub"
},
{
"SubItem": "The C2 sub"
}
]
}
]
}
You should have two models and a viewModel like this in your project:
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
BindingContext = new viewModel();
}
public class subModel
{
public string SubItem { get; set; }
}
public class Data
{
public string Category { get; set; }
public IList<subModel> List { get; set; }
}
public class viewModel {
public ObservableCollection<Data> items = new ObservableCollection<Data>();
public viewModel() {
}
}
In the xaml, bind to a grouped CollectionView:
<CollectionView ItemsSource="{Binding items}"
IsGrouped="true">
<CollectionView.ItemTemplate>
<DataTemplate>
<Label Text="{Binding SubItem}"/>
</DataTemplate>
</CollectionView.ItemTemplate>
<CollectionView.GroupHeaderTemplate>
<DataTemplate>
<Label Text="{Binding Category}" />
</DataTemplate>
</CollectionView.GroupHeaderTemplate>
</CollectionView>

Gridsome source-filesystem add tag description

I'm using #gridsome/source-filesystem with this config:
{
use: '#gridsome/source-filesystem',
options: {
typeName: 'Post',
path: 'content/posts/**/*.md',
refs: {
tags: {
typeName: 'Tag',
create: true
},
author: {
typeName: 'Author',
create: true
}
}
},
}
Now I want to add description for one tag only, so I created a new doc in content/posts/my-tag.md:
---
title: Tag-Title
description:tag description
---
How can I connect this document to the allTags collection?
Or any other way (without #gridsome/source-filesystem for Tags, for example), to add description to exists node in collection?
If you want to just add allTags, you can create markdown for it.
in gridsome.config.js
...
{
use: '#gridsome/source-filesystem',
options: {
path: 'content/tags/**/*.md',
typeName: 'Tag'
},
}
...
add file content/tags/my-tag.md
---
title: Tag-Title
description: tag description
---
you can explole
{
allTag {
edges {
node {
id
title
description
}
}
}
}
{
"data": {
"allTag": {
"edges": [
{
"node": {
"id": "******", // random hash
"title": "Tag-Title",
"description": "tag description"
}
},
{
"node": {
"id": "foo",
"title": "foo",
"description": ""
}
},
...
but, this is not able to connect to your Post.
or just added description to Tag, you can use addSchemaResolvers.
in gridsome.server.js
module.exports = function(api) {
api.loadSource(async ({ addSchemaResolvers }) => {
addSchemaResolvers({
Tag: {
description: {
type: "String",
resolve(obj) {
if (!obj.description) {
// coding your logic
return "set description";
} else {
return obj.description;
}
}
}
}
});
});
};

How to pass/receive item detail from ListView tap event in Nativescript/JS?

What I want to do (I think) is get the store.id from itemTap event and pass it along with the .navigate() so I can use it to fetch the correct data for the detail page, however I can't figure out how to get the tapped item.
I've got a list-page.xml:
<Page loaded="loaded" xmlns:lv="nativescript-ui-listview">
<ActionBar title="Bars"></ActionBar>
<GridLayout>
<ListView items="{{ storeList }}" row="1" itemTap="showDetail">
<ListView.itemTemplate >
<GridLayout class="grocery-list-item" >
<Label class="p-15" text="{{ name }}" />
</GridLayout>
</ListView.itemTemplate>
</ListView>
</GridLayout>
and list-page.js:
var dialogsModule = require("tns-core-modules/ui/dialogs");
var observableModule = require("tns-core-modules/data/observable");
var ObservableArray = require("tns-core-modules/data/observable-array").ObservableArray;
var page;
var StoreListViewModel = require("../shared/view-models/store-list-view-model");
var frameModule = require("tns-core-modules/ui/frame");
var storeList = new StoreListViewModel([]);
var pageData = new observableModule.fromObject({
storeList:storeList
});
exports.loaded = function (args) {
page = args.object;
page.bindingContext = pageData;
sindex = args.object.bindingContext;
storeList.empty();
storeList.load();
};
exports.showDetail = function() {
frameModule.topmost().navigate("views/detail/detail-page");
};
The storeList comes from my api and successfully sends back a list of stores which are rendered by the listview.
I've looked at a dozen other tutorials/questions, and several seem to mention getting it from either the args.index or args.object.bindingContext, but when I console.log(args.index) from the showDetail function, it's undefined. console.log(args.object.bindingContext) gives me a bunch of data, but it's identical regardless which row I click....
CONSOLE LOG file:///app/bundle.js:359:12: {
"_observers": {
"propertyChange": [
{}
]
},
"_map": {
"storeList": {
"_observers": {
"change": [
{}
]
},
"_array": [
{
"name": "Hipster's Coffee",
"address": "2200 Broadway, Oakland, CA 94612",
"id": 2
},
{
"name": "Suzy's Stationary",
"address": "630 Divisadero St., San Francisco, CA 94117",
"id": 3
}
],
"_addArgs": {
"eventName": "change",
"object": "[Circular]",
"action": "add",
"index": 1,
"removed": [],
"addedCount": 1
},
"_deleteArgs": {
"eventName": "change",
"object": "[Circular]",
"action": "delete",
"index": null,
"removed": null,
"addedCount": 0
}
}
},
"storeList": "[Circular]"
}
I'm very new to NativeScript, so obviously I'm missing something simple here.
<ListView items="{{ storeList }}" row="1" itemTap="{{showDetail}}">
Look at the sample playground here.
The function showDetail needs to access the received arguments. Just change the following in your code-behind file:
exports.showDetail = function(args) {
console.log(args); // Now there are arguments received from the itemTap event
frameModule.topmost().navigate("views/detail/detail-page");
};
Eventually figured out the proper way to extract the item details from the args:
var item = args.view.bindingContext;
and then I could access item.name, item.id, etc. and pass it through like so:
var navigationOptions={
moduleName:'views/detail/detail-page',
context:{
store_id: item.id
}
}
frameModule.topmost().navigate(navigationOptions);

Mongo query in Spring Boot

Please help me to get the below complex mongo query using mongoTemplate in spring
i would like to retrieve the collection only if "NAME": "UserID1"?
{
"_id": "12345",
"A": [{
"B1": {
"NAME": "test1",
"C1": [{
"D1": [{
"NAME": "UserID1"
},
{
"NAME": "UserID2"
}
]
}]
}
},
{
"B2": {
"NAME": "test2",
"C2": [{
"D2": [{
"NAME": "UserID3"
},
{
"NAME": "UserID4"
}
]
}]
}
}]
}
Thanks.
for example if assume your class like this:
#Document
public class FirstClass{
#Id
String id;
List<SecondClass> A;
public class SecondClass{
string Name;
List<ThirdClass> C1;
}
}
in mongoTemplate:
...
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
...
#Component
public ServiceClass{
private final MongoTemplate mongoTemplate;
ServiceClass(MongoTemplate mongoTemplate){
this.mongoTemplate = mongoTemplate;
}
public List<FirstClass> getResult(String searchInput){
final Criteria criteria =
Criteria.where("A.name").is(searchInput);
List<FirstClass> result = mongoTemplate.find(new Query(criteria),FirstClass.class);
}
}
and you can use spring data mongo query like this:
public interface FirstClassRepository extends MongoRepository<FirstClass, String> {
List<FirstClass> findByA_Name(String name);
}

Resources