From 002a64106f1027ea4f7b85d1bdddb10c2ae1314f Mon Sep 17 00:00:00 2001 From: walljm Date: Sat, 21 Jan 2017 00:15:00 -0500 Subject: [PATCH] FEATURE: Added icons, Update page with current results, current page label * fixed colors, some bugs * moved saved pages action to actions menu * updated settings with nicer buttons/layout --- DynamicBibleIonic/package.json | 9 ++- DynamicBibleIonic/src/app/app.component.ts | 14 +++- DynamicBibleIonic/src/app/app.html | 7 +- .../src/components/passage/passage.html | 2 +- .../src/components/passage/passage.scss | 14 ++-- .../strongs-modal/strongs-modal.html | 2 +- .../src/components/strongs/strongs.html | 2 +- .../src/components/words/words.html | 2 +- .../src/pages/search/search.html | 45 +++++++----- .../src/pages/search/search.scss | 6 +- DynamicBibleIonic/src/pages/search/search.ts | 73 +++++++++++++++---- .../src/pages/settings/settings.html | 36 ++++----- .../src/pages/settings/settings.ts | 36 +++++++-- .../src/services/pages-service.ts | 16 ++-- 14 files changed, 179 insertions(+), 85 deletions(-) diff --git a/DynamicBibleIonic/package.json b/DynamicBibleIonic/package.json index ff227ad4..4953c93e 100644 --- a/DynamicBibleIonic/package.json +++ b/DynamicBibleIonic/package.json @@ -28,14 +28,15 @@ "@angular/platform-server": "2.2.1", "@ionic/storage": "1.1.7", "@types/jasmine": "^2.5.38", - "ionic-angular": "2.0.0-rc.4", + "ionic-angular": "2.0.0-rc.5", "ionic-native": "2.2.11", "ionicons": "3.0.0", "rxjs": "5.0.0-beta.12", - "zone.js": "0.6.26" + "zone.js": "0.6.26", + "sw-toolbox": "3.4.0" }, "devDependencies": { - "@ionic/app-scripts": "0.0.47", + "@ionic/app-scripts": "1.0.0", "@types/jasmine": "2.5.38", "@types/node": "6.0.42", "angular-cli": "1.0.0-beta.24", @@ -53,7 +54,7 @@ "ts-node": "1.7.2", "tslint": "4.1.1", "tslint-eslint-rules": "3.2.0", - "typescript": "2.0.10" + "typescript": "2.0.9" }, "cordovaPlugins": [ "cordova-plugin-whitelist", diff --git a/DynamicBibleIonic/src/app/app.component.ts b/DynamicBibleIonic/src/app/app.component.ts index b523c657..d984d761 100644 --- a/DynamicBibleIonic/src/app/app.component.ts +++ b/DynamicBibleIonic/src/app/app.component.ts @@ -38,7 +38,19 @@ export class MyApp openPage(page) { // close the menu when clicking a link from the menu - this.menu.close(); + this.menu.close('pages'); + + // because the actions menu is on a Page component, and you swap the SearchPage out, + // the menu get registered multiple times. to avoid some pages not opening the menu because + // multiple menus with the same id exist and the first one in the list is returned (which happens + // be disabled when another of the same id is added) it won't show. because not enabled. + // --- + // unregistering the actions menu whenever a new page is opened fixes the problem, because the menu + // will get reregistered when SearchPage loads. Also, if you go to a non SearchPage, the actions + // menu won't be there, but the unregister function doesn't fail if a non existent id is given, + // so thats ok. + this.menu.unregister(this.menu.get('actions')); + // navigate to the new page if it is not the current page this.nav.setRoot(page.component, page.params); } diff --git a/DynamicBibleIonic/src/app/app.html b/DynamicBibleIonic/src/app/app.html index d94b4b30..fad3de0a 100644 --- a/DynamicBibleIonic/src/app/app.html +++ b/DynamicBibleIonic/src/app/app.html @@ -1,4 +1,4 @@ - + Pages @@ -7,7 +7,7 @@ @@ -15,9 +15,10 @@ Saved Pages + \ No newline at end of file diff --git a/DynamicBibleIonic/src/components/passage/passage.html b/DynamicBibleIonic/src/components/passage/passage.html index a53e52a9..948e4f1b 100644 --- a/DynamicBibleIonic/src/components/passage/passage.html +++ b/DynamicBibleIonic/src/components/passage/passage.html @@ -1,5 +1,5 @@ - {{item.ref}} + {{item.ref}} diff --git a/DynamicBibleIonic/src/components/passage/passage.scss b/DynamicBibleIonic/src/components/passage/passage.scss index ec9c96a6..9a46c869 100644 --- a/DynamicBibleIonic/src/components/passage/passage.scss +++ b/DynamicBibleIonic/src/components/passage/passage.scss @@ -1,17 +1,19 @@ -.passage-title { - background-color: #c3cce4; +passage .button-clear-md { + color: #3D5699; } +.passage-title { + background-color: #c3cce4; +} passage .passage-text { padding-bottom: 12px; } -.passage-text + .passage-text -{ +.passage-text + .passage-text { border-top: 1px dotted #808080; padding-top: 12px; -} +} @media screen and (min-width: 800px) { passage .passage-text { @@ -28,4 +30,4 @@ passage .passage-text { -moz-column-rule-width: 1px; /* Firefox */ column-rule-width: 1px; } -} +} \ No newline at end of file diff --git a/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.html b/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.html index 79f8b865..62a967eb 100644 --- a/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.html +++ b/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.html @@ -1,7 +1,7 @@ - Strongs: {{item.prefix}}{{item.sn}} + Strongs: {{item.prefix}}{{item.sn}} diff --git a/DynamicBibleIonic/src/components/words/words.html b/DynamicBibleIonic/src/components/words/words.html index 0c6b24d8..db19cd37 100644 --- a/DynamicBibleIonic/src/components/words/words.html +++ b/DynamicBibleIonic/src/components/words/words.html @@ -1,5 +1,5 @@ - {{item.refs.length}} results for {{item.word}} + {{item.refs.length}} results for {{item.word}} diff --git a/DynamicBibleIonic/src/pages/search/search.html b/DynamicBibleIonic/src/pages/search/search.html index 5e7ca6a4..1f283d29 100644 --- a/DynamicBibleIonic/src/pages/search/search.html +++ b/DynamicBibleIonic/src/pages/search/search.html @@ -1,31 +1,38 @@ + + + + Actions + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + CURRENT PAGE: {{title}} diff --git a/DynamicBibleIonic/src/pages/search/search.scss b/DynamicBibleIonic/src/pages/search/search.scss index dacb4251..a64566bc 100644 --- a/DynamicBibleIonic/src/pages/search/search.scss +++ b/DynamicBibleIonic/src/pages/search/search.scss @@ -17,7 +17,7 @@ a { color: black; - border-bottom: 1px dotted gainsboro; + border-bottom: 1px dotted #ccc; } } @@ -36,4 +36,8 @@ body { .item-md.item-block .item-inner { padding: 0px; +} + +.item-md ion-icon[item-left] + .item-inner { + margin-left: 6px; } \ No newline at end of file diff --git a/DynamicBibleIonic/src/pages/search/search.ts b/DynamicBibleIonic/src/pages/search/search.ts index 7b4055b2..f91af05d 100644 --- a/DynamicBibleIonic/src/pages/search/search.ts +++ b/DynamicBibleIonic/src/pages/search/search.ts @@ -1,5 +1,5 @@ import { Type, Component } from '@angular/core'; -import { Loading, LoadingController, ModalController, NavParams } from 'ionic-angular'; +import { Loading, LoadingController, ModalController, NavParams, AlertController, MenuController } from 'ionic-angular'; import { Storage } from '@ionic/storage'; import { StrongsModal } from '../../components/strongs-modal/strongs-modal'; @@ -23,17 +23,19 @@ export class SearchPage userProfile: UserProfile; last: CardItem; loader: Loading; - saved_results_title: string = ""; + title: string; constructor( - private strongsService: StrongsService - ,private bibleService: BibleService - ,private wordService: WordService - ,private pagesService: PagesService - ,public loadingCtrl: LoadingController - ,public modalCtrl: ModalController - ,public local: Storage - ,public params: NavParams + private strongsService: StrongsService + , private bibleService: BibleService + , private wordService: WordService + , private pagesService: PagesService + , private alertCtrl: AlertController + , private menu: MenuController + , public loadingCtrl: LoadingController + , public modalCtrl: ModalController + , public local: Storage + , public params: NavParams ) { this.userProfile = new UserProfile(UserProfile.createDefaultUser()); @@ -54,13 +56,54 @@ export class SearchPage console.log(error); }); } + + actionsMenu() + { + this.menu.open('actions'); + } addPage() { - let p = { queries: this.userProfile.user.items.slice(), title: this.saved_results_title }; - this.userProfile.user.saved_pages.push(p); + let alert = this.alertCtrl.create({ + title: 'Save Search as Page', + inputs: [ + { + name: 'title', + placeholder: 'Page Title' + } + ], + buttons: [ + { + text: 'Cancel', + role: 'cancel', + handler: data => + { + console.log('Cancel clicked'); + } + }, + { + text: 'Save', + handler: data => + { + let p = { queries: this.userProfile.user.items.slice(), title: data.title }; + this.userProfile.user.saved_pages.push(p); + this.userProfile.save(this.local); + this.pagesService.addPage(p); + } + } + ] + }); + alert.present(); + } + + updatePage() + { + let page = this.userProfile.user.saved_pages.find( + i=> + i.title == this.params.data.title + ); + page.queries = this.userProfile.user.items.slice(); this.userProfile.save(this.local); - this.pagesService.addPage(p); } initializeItems(u: UserProfile) @@ -69,6 +112,10 @@ export class SearchPage this.pagesService.initializePages(u.user.saved_pages); if (this.params.data.queries !== undefined) this.userProfile.user.items = this.params.data.queries.slice(); + if (this.params.data.title === undefined) + this.title = "Search"; + else + this.title = this.params.data.title; } presentStrongsModal(strongs: StrongsResult) diff --git a/DynamicBibleIonic/src/pages/settings/settings.html b/DynamicBibleIonic/src/pages/settings/settings.html index fd440506..e14ebbb8 100644 --- a/DynamicBibleIonic/src/pages/settings/settings.html +++ b/DynamicBibleIonic/src/pages/settings/settings.html @@ -8,17 +8,7 @@ \ No newline at end of file diff --git a/DynamicBibleIonic/src/pages/settings/settings.ts b/DynamicBibleIonic/src/pages/settings/settings.ts index 7272e205..6b4bfae9 100644 --- a/DynamicBibleIonic/src/pages/settings/settings.ts +++ b/DynamicBibleIonic/src/pages/settings/settings.ts @@ -1,6 +1,6 @@ /// import { Component } from '@angular/core'; -import { NavController } from 'ionic-angular'; +import { NavController, AlertController } from 'ionic-angular'; import { Storage } from '@ionic/storage'; import { SavedPage, UserProfile } from '../../libs/UserProfile'; @@ -13,7 +13,10 @@ export class SettingsPage textSize: number = 0; userProfile: UserProfile; - constructor(public navCtrl: NavController, public local: Storage) + constructor( + public navCtrl: NavController + , public local: Storage + , private alertCtrl: AlertController) { this.userProfile = new UserProfile(UserProfile.createDefaultUser()); @@ -50,10 +53,31 @@ export class SettingsPage removePage(page: SavedPage) { - let idx = this.userProfile.user.saved_pages.indexOf(page); - this.userProfile.user.saved_pages.splice(idx, 1); + let alert = this.alertCtrl.create({ + title: 'Confirm Delete', + message: 'Do you want to delete the ' + page.title + ' page?', + buttons: [ + { + text: 'Cancel', + role: 'cancel', + handler: () => + { + console.log('Cancel clicked'); + } + }, + { + text: 'Ok', + handler: () => + { + let idx = this.userProfile.user.saved_pages.indexOf(page); + this.userProfile.user.saved_pages.splice(idx, 1); - // save the users settings. - this.userProfile.save(this.local); + // save the users settings. + this.userProfile.save(this.local); + } + } + ] + }); + alert.present(); } } \ No newline at end of file diff --git a/DynamicBibleIonic/src/services/pages-service.ts b/DynamicBibleIonic/src/services/pages-service.ts index e32f8897..0cf6e1c8 100644 --- a/DynamicBibleIonic/src/services/pages-service.ts +++ b/DynamicBibleIonic/src/services/pages-service.ts @@ -7,14 +7,14 @@ import { SavedPage } from "../libs/UserProfile"; @Injectable() export class PagesService { - pages: Array<{ title: string, component: any, params: any }>; + pages: Array<{ title: string, component: any, params: any, icon: string }>; savedPages: Array<{ title: string, component: any, params: any }>; constructor(public local: Storage) { this.pages = [ - { title: 'Search', component: SearchPage, params: { queries: []} }, - { title: 'Settings', component: SettingsPage, params: {} } + { title: 'Search', component: SearchPage, params: { queries: [], title: "Search" }, icon: "search" }, + { title: 'Settings', component: SettingsPage, params: {}, icon: "settings" } ]; this.savedPages = []; } @@ -23,7 +23,7 @@ export class PagesService { return this.pages; } - + getSavedPages(): Array<{ title: string, component: any }> { return this.savedPages; @@ -31,20 +31,16 @@ export class PagesService addPage(page: SavedPage) { - this.savedPages.push({ title: page.title, component: SearchPage, params: { queries: page.queries } }); + this.savedPages.push({ title: page.title, component: SearchPage, params: { queries: page.queries, title: page.title } }); } initializePages(page_array: SavedPage[]) { - this.pages = [ - { title: 'Search', component: SearchPage, params: { queries: [] } }, - { title: 'Settings', component: SettingsPage, params: {} } - ]; this.savedPages = []; for (let p of page_array) { - this.savedPages.push({ title: p.title, component: SearchPage, params: { queries: p.queries } }); + this.savedPages.push({ title: p.title, component: SearchPage, params: { queries: p.queries, title: p.title } }); } } } \ No newline at end of file