Skip to content

Commit

Permalink
Missed some files from last commit. Also new npm token since the inci…
Browse files Browse the repository at this point in the history
…dent.
  • Loading branch information
ascott18 committed Jul 13, 2018
1 parent cc264ce commit 156bb92
Show file tree
Hide file tree
Showing 5 changed files with 214 additions and 1 deletion.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ environment:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
NET_CORE_VERSION: netcoreapp2.1
NPM_TOKEN:
secure: PpvAZnPCnGvKx69JHFV2FowUIpo0jgV1g1jJpuuPmDyZij9RwMcjuGIAKfsSiaQH
secure: dQCkkO4ezshvOI5/8Tml4T0EnIxjHv7nrXFsnq9dStEGBbcQNIWhb+gOBn9lacYs

image: Visual Studio 2017
cache:
Expand Down
7 changes: 7 additions & 0 deletions src/coalesce-vue/test/targets.apiclients.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { ModelApiClient } from "@/api-client";
import * as $models from "./targets.models"
import * as $metadata from "./targets.metadata"

export class StudentApiClient extends ModelApiClient<$models.Student> {
constructor() { super($metadata.Student) }
}
164 changes: 164 additions & 0 deletions src/coalesce-vue/test/targets.metadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
import { ObjectType, BasicCollectionProperty, getEnumMeta, ObjectProperty, ModelType, ModelCollectionNavigationProperty, ClassType } from "@/metadata";

const metaBase = (name: string = "model") => {
return {
name: name,
displayName: name.substr(0, 1).toUpperCase() + name.substr(1)
};
};

const value = (name: string = "prop") => {
return {
name: name,
displayName: name.substr(0, 1).toUpperCase() + name.substr(1),
role: "value"
};
};

const Types: { [key: string]: ClassType } = {};
export default Types;

export const Course = Types.Course = <ModelType>{
...metaBase("course"),
type: "model",
get keyProp() {
return this.props.courseId;
},
get displayProp() {
return this.props.name;
},
controllerRoute: "Courses",
dataSources: {},
methods: {},
props: {
courseId: {
...value("courseId"),
type: "number"
},
name: {
...value("name"),
type: "string"
}
}
};

export const Advisor = Types.Advisor = <ModelType>{
...metaBase("advisor"),
type: "model",
get keyProp() {
return this.props.advisorId;
},
get displayProp() {
return this.props.name;
},
controllerRoute: "Advisors",
dataSources: {},
methods: {},
props: {
advisorId: {
...value("advisorId"),
type: "number"
},
name: {
...value("name"),
type: "string"
}
}
};

export const Student = Types.Student = <ModelType>{
...metaBase("student"),
type: "model",
get displayProp() {
return this.props.name;
},
get keyProp() {
return this.props.studentId;
},
controllerRoute: "Students",
dataSources: {},
methods: {},
props: {
studentId: {
...value("studentId"),
type: "number"
},
name: {
...value("name"),
type: "string"
},
isEnrolled: {
...value("isEnrolled"),
type: "boolean"
},
birthDate: {
...value("birthDate"),
type: "date"
},
courses: <ModelCollectionNavigationProperty>{
...value("courses"),
role: "collectionNavigation",
type: "collection",
dontSerialize: true,
itemType: {
...value("$collectionValue"),
type: "model",
typeDef: Course,
}
},
grade: {
...value("grade"),
type: "enum",
typeDef: {
name: "grades",
displayName: "Grades",
type: "enum",
...getEnumMeta([
{ value: 9, strValue: "Freshman", displayName: "Freshman" },
{ value: 10, strValue: "Sophomore", displayName: "Sophomore" },
{ value: 11, strValue: "Junior", displayName: "Junior" },
{ value: 12, strValue: "Senior", displayName: "Senior" }
])
}
},
advisor: {
name: "advisor",
displayName: "Advisor",
type: "model",
role: "referenceNavigation",
dontSerialize: true,
get foreignKey() { return Types.Student.props.advisorId },
get principalKey() { return Advisor.keyProp },
typeDef: Advisor
},
advisorId: {
name: "advisorId",
displayName: "AdvisorId",
type: "number",
role: "foreignKey",
get navigationProp() { return Types.Student.props.advisor },
get principalType() { return Types.Advisor },
get principalKey() { return Advisor.keyProp }
}
}
};

export const DisplaysStudent = <ObjectType>{
...metaBase("displaysStudent"),
type: "object",
get displayProp() {
return this.props.student;
},
props: {
name: {
...value("name"),
type: "string"
},
student: {
...value("student"),
type: "model",
dontSerialize: true,
typeDef: Student
}
}
};
30 changes: 30 additions & 0 deletions src/coalesce-vue/test/targets.models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as metadata from './targets.metadata'
import { Model, DataSource, convertToModel, mapToModel } from '@/model'

export enum Grade {
Freshman = 9,
Sophomore = 10,
Junior = 11,
Senior = 12,
}

export interface Student extends Model<typeof metadata.Student> {
studentId: number | null
name: string | null
isEnrolled: boolean | null
birthDate: Date | null
courses: Course[] | null
grade: Grade | null
advisor: Advisor | null
advisorId: number | null
}

export interface Advisor extends Model<typeof metadata.Advisor> {
advisorId: number | null
name: string | null
}

export interface Course extends Model<typeof metadata.Course> {
courseId: number | null
name: string | null
}
12 changes: 12 additions & 0 deletions src/coalesce-vue/test/targets.viewmodels.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as metadata from "./targets.metadata"
import * as models from "./targets.models"
import * as apiClients from "./targets.apiclients"
import { ViewModel, ListViewModel, defineProps } from '@/viewmodel'

export interface StudentViewModel extends models.Student {}
export class StudentViewModel extends ViewModel<models.Student, apiClients.StudentApiClient> {
constructor(initialData?: models.Student) {
super(metadata.Student, new apiClients.StudentApiClient(), initialData)
}
}
defineProps(StudentViewModel, metadata.Student)

0 comments on commit 156bb92

Please sign in to comment.