-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
61 changed files
with
662 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { FirestoreQueryConstraint, where } from "@dereekb/firebase"; | ||
|
||
export function guestbookEntryWithUsername(username: string): FirestoreQueryConstraint { | ||
return where('username', '==', username); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import { CollectionReference, AbstractFirestoreDocument, makeSnapshotConverterFunctions, firestoreString, firestoreDate, FirestoreCollection, UserRelatedById, DocumentReferenceRef, FirestoreContext, FirestoreCollectionWithParent, firestoreBoolean } from "@dereekb/firebase"; | ||
|
||
export interface GuestbookFirestoreCollections { | ||
guestbookFirestoreCollection: GuestbookFirestoreCollection; | ||
guestbookEntryCollectionFactory: GuestbookEntryFirestoreCollectionFactory; | ||
} | ||
|
||
// MARK: Guestbook | ||
export interface Guestbook { | ||
/** | ||
* Whether or not this guestbook should show up in the list. | ||
* | ||
* If not active, this item is still considered locked. | ||
*/ | ||
active: boolean; | ||
/** | ||
* Guestbook name | ||
*/ | ||
name: string; | ||
/** | ||
* Whether or not this guestbook and it's entries can still be edited. | ||
*/ | ||
locked: boolean; | ||
/** | ||
* Last date the guestbook was updated at. | ||
*/ | ||
lockedAt: Date; | ||
} | ||
|
||
export interface GuestbookRef extends DocumentReferenceRef<Guestbook> { } | ||
|
||
export class GuestbookDocument extends AbstractFirestoreDocument<Guestbook, GuestbookDocument> { } | ||
|
||
export const guestbookCollectionPath = 'guestbook'; | ||
|
||
export const guestbookConverter = makeSnapshotConverterFunctions<Guestbook>({ | ||
fields: { | ||
active: firestoreBoolean(), | ||
name: firestoreString(), | ||
locked: firestoreBoolean(), | ||
lockedAt: firestoreDate() | ||
} | ||
}); | ||
|
||
export function guestbookCollectionReference(context: FirestoreContext): CollectionReference<Guestbook> { | ||
return context.collection(guestbookCollectionPath).withConverter<Guestbook>(guestbookConverter); | ||
} | ||
|
||
export type GuestbookFirestoreCollection = FirestoreCollection<Guestbook, GuestbookDocument>; | ||
|
||
export function guestbookFirestoreCollection(firestoreContext: FirestoreContext): GuestbookFirestoreCollection { | ||
return firestoreContext.firestoreCollection({ | ||
itemsPerPage: 50, | ||
collection: guestbookCollectionReference(firestoreContext), | ||
makeDocument: (accessor, documentAccessor) => new GuestbookDocument(accessor, documentAccessor), | ||
firestoreContext | ||
}); | ||
} | ||
|
||
// MARK: Guestbook Entry | ||
export interface GuestbookEntry extends UserRelatedById { | ||
/** | ||
* Arbitrary word without spaces | ||
*/ | ||
word: string; | ||
/** | ||
* Guestbook message. | ||
*/ | ||
message: string; | ||
/** | ||
* Arbitrary string for signature | ||
*/ | ||
signed: string; | ||
/** | ||
* Date the entry was last updated at. | ||
*/ | ||
updatedAt: Date; | ||
/** | ||
* Date the entry was originally created at. | ||
*/ | ||
createdAt: Date; | ||
} | ||
|
||
export interface GuestbookEntryRef extends DocumentReferenceRef<GuestbookEntry> { } | ||
|
||
export class GuestbookEntryDocument extends AbstractFirestoreDocument<GuestbookEntry, GuestbookEntryDocument> { } | ||
|
||
export const guestbookEntryCollectionPath = 'guestbookEntry'; | ||
|
||
export const guestbookEntryConverter = makeSnapshotConverterFunctions<GuestbookEntry>({ | ||
fields: { | ||
word: firestoreString(), | ||
message: firestoreString(), | ||
signed: firestoreString(), | ||
updatedAt: firestoreDate(), | ||
createdAt: firestoreDate({ saveDefaultAsNow: true }) | ||
} | ||
}); | ||
|
||
export function guestbookEntryCollectionReferenceFactory(context: FirestoreContext): (guestbook: GuestbookDocument) => CollectionReference<GuestbookEntry> { | ||
return (guestbook: GuestbookDocument) => { | ||
return context.subcollection(guestbook.documentRef, guestbookEntryCollectionPath).withConverter<GuestbookEntry>(guestbookEntryConverter); | ||
}; | ||
} | ||
|
||
export type GuestbookEntryFirestoreCollection = FirestoreCollectionWithParent<GuestbookEntry, Guestbook, GuestbookEntryDocument>; | ||
export type GuestbookEntryFirestoreCollectionFactory = (parent: GuestbookDocument) => GuestbookEntryFirestoreCollection; | ||
|
||
export function guestbookEntryFirestoreCollectionFactory(firestoreContext: FirestoreContext): GuestbookEntryFirestoreCollectionFactory { | ||
const factory = guestbookEntryCollectionReferenceFactory(firestoreContext); | ||
|
||
return (parent: GuestbookDocument) => { | ||
return firestoreContext.firestoreCollectionWithParent({ | ||
itemsPerPage: 50, | ||
collection: factory(parent), | ||
makeDocument: (accessor, documentAccessor) => new GuestbookEntryDocument(accessor, documentAccessor), | ||
firestoreContext, | ||
parent | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './guestbook'; | ||
export * from './guestbook.query'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './guestbook'; | ||
export * from './profile'; | ||
export * from './collection'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
apps/demo/src/app/modules/demo/modules/app/modules/guestbook/container/layout.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<ui-view></ui-view> |
6 changes: 6 additions & 0 deletions
6
apps/demo/src/app/modules/demo/modules/app/modules/guestbook/container/layout.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
templateUrl: './layout.component.html' | ||
}) | ||
export class DemoGuestbookLayoutComponent {} |
7 changes: 7 additions & 0 deletions
7
apps/demo/src/app/modules/demo/modules/app/modules/guestbook/container/list.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<dbx-two-column> | ||
<dbx-two-block left> | ||
<dbx-two-column-head top></dbx-two-column-head> | ||
<demo-guestbook-list></demo-guestbook-list> | ||
</dbx-two-block> | ||
<ui-view right></ui-view> | ||
</dbx-two-column> |
10 changes: 10 additions & 0 deletions
10
apps/demo/src/app/modules/demo/modules/app/modules/guestbook/container/list.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
templateUrl: './list.component.html' | ||
}) | ||
export class DemoGuestbookListPageComponent { | ||
|
||
constructor() { } | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
...mo/src/app/modules/demo/modules/app/modules/guestbook/container/list.right.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<dbx-two-column-right header="Guestbook"> | ||
<dbx-content-container> | ||
<p>View Guest Book</p> | ||
</dbx-content-container> | ||
</dbx-two-column-right> |
6 changes: 6 additions & 0 deletions
6
...demo/src/app/modules/demo/modules/app/modules/guestbook/container/list.right.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
templateUrl: './list.right.component.html' | ||
}) | ||
export class DemoGuestbookListPageRightComponent {} |
22 changes: 22 additions & 0 deletions
22
apps/demo/src/app/modules/demo/modules/app/modules/guestbook/guestbook.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { UIRouterModule } from '@uirouter/angular'; | ||
import { STATES } from './guestbook.router'; | ||
import { DemoAppSharedModule } from '../../../shared/demo.app.shared.module'; | ||
import { DemoGuestbookListPageRightComponent } from './container/list.right.component'; | ||
import { DemoGuestbookListPageComponent } from './container/list.component'; | ||
import { DemoGuestbookLayoutComponent } from './container/layout.component'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
DemoAppSharedModule, | ||
UIRouterModule.forChild({ | ||
states: STATES | ||
}) | ||
], | ||
declarations: [ | ||
DemoGuestbookLayoutComponent, | ||
DemoGuestbookListPageComponent, | ||
DemoGuestbookListPageRightComponent | ||
], | ||
}) | ||
export class DemoGuestbookModule { } |
27 changes: 27 additions & 0 deletions
27
apps/demo/src/app/modules/demo/modules/app/modules/guestbook/guestbook.router.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Ng2StateDeclaration } from '@uirouter/angular'; | ||
import { DemoGuestbookLayoutComponent } from './container/layout.component'; | ||
import { DemoGuestbookListPageComponent } from './container/list.component'; | ||
import { DemoGuestbookListPageRightComponent } from './container/list.right.component'; | ||
|
||
export const layoutState: Ng2StateDeclaration = { | ||
url: '/guestbook', | ||
name: 'demo.app.guestbook', | ||
redirectTo: 'demo.app.guestbook.list', | ||
component: DemoGuestbookLayoutComponent | ||
}; | ||
|
||
export const guestbookListState: Ng2StateDeclaration = { | ||
name: 'demo.app.guestbook.list', | ||
component: DemoGuestbookListPageComponent | ||
}; | ||
|
||
export const guestbookListRightState: Ng2StateDeclaration = { | ||
url: '/:id', | ||
name: 'demo.app.guestbook.list.guestbook', | ||
component: DemoGuestbookListPageRightComponent | ||
}; | ||
|
||
export const STATES: Ng2StateDeclaration[] = [ | ||
layoutState, | ||
guestbookListState | ||
]; |
3 changes: 3 additions & 0 deletions
3
apps/demo/src/app/modules/demo/modules/app/modules/profile/container/layout.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<dbx-content-container> | ||
<ui-view></ui-view> | ||
</dbx-content-container> |
6 changes: 6 additions & 0 deletions
6
apps/demo/src/app/modules/demo/modules/app/modules/profile/container/layout.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
templateUrl: './layout.component.html' | ||
}) | ||
export class DemoProfileLayoutComponent {} |
1 change: 1 addition & 0 deletions
1
apps/demo/src/app/modules/demo/modules/app/modules/profile/container/profile.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>Profile</p> |
6 changes: 6 additions & 0 deletions
6
apps/demo/src/app/modules/demo/modules/app/modules/profile/container/profile.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
templateUrl: './profile.component.html' | ||
}) | ||
export class DemoProfileViewComponent {} |
20 changes: 20 additions & 0 deletions
20
apps/demo/src/app/modules/demo/modules/app/modules/profile/profile.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { DemoProfileViewComponent } from './container/profile.component'; | ||
import { DemoProfileLayoutComponent } from './container/layout.component'; | ||
import { NgModule } from '@angular/core'; | ||
import { UIRouterModule } from '@uirouter/angular'; | ||
import { STATES } from './profile.router'; | ||
import { AppSharedModule } from '@/shared/app.shared.module'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
AppSharedModule, | ||
UIRouterModule.forChild({ | ||
states: STATES | ||
}) | ||
], | ||
declarations: [ | ||
DemoProfileLayoutComponent, | ||
DemoProfileViewComponent | ||
], | ||
}) | ||
export class DemoProfileModule { } |
Oops, something went wrong.