src/pages/utilities/utilities.ts
Generated class for the UtilitiesPage page.
See https://ionicframework.com/docs/components/#navigation for more info on Ionic pages and navigation.
selector | page-utilities |
templateUrl | utilities.html |
Properties |
Methods |
alertSing |
alertSing()
|
Defined in src/pages/utilities/utilities.ts:98
|
Returns :
void
|
openModal |
openModal()
|
Defined in src/pages/utilities/utilities.ts:86
|
Opens the About page modal
Returns :
void
|
empty_bucket |
empty_bucket:
|
Type : number
|
Default value : 2.0
|
Defined in src/pages/utilities/utilities.ts:47
|
filled_bucket |
filled_bucket:
|
Type : number
|
Default value : 10.0
|
Defined in src/pages/utilities/utilities.ts:48
|
hello |
hello:
|
Default value : (() => {
if (!this.empty_bucket || !this.filled_bucket || !this.single_item) {
return 'Weight inputs cannot be empty';
}
if (this.empty_bucket <= 0 || this.filled_bucket <= 0 || this.single_item <= 0 ) {
return 'Weight value must be a positive value';
}
if (this.single_item - this.filled_bucket > 0) {
return 'Single item cannot weigh more than a filled bucket';
}
if (this.empty_bucket - this.filled_bucket >= 0) {
return 'Empty bucket cannot weigh more than a filled bucket';
}
return 'Total items: ' + Math.floor((this.filled_bucket - this.empty_bucket) / this.single_item);
})
|
Defined in src/pages/utilities/utilities.ts:55
|
Determines what is the resulting weight value to be displayed. Handles invalid input values by returning appropriate validation messages |
Math |
Math:
|
Type : Math
|
Default value : Math
|
Defined in src/pages/utilities/utilities.ts:44
|
An instance of the JavaScript Math class required to use the floor function |
single_item |
single_item:
|
Type : number
|
Default value : 1.0
|
Defined in src/pages/utilities/utilities.ts:46
|
import { Component } from '@angular/core';
import { NavController, NavParams, AlertController} from 'ionic-angular';
import { ModalController } from 'ionic-angular';
// import { ContactPage } from '../contact/contact';
import { AboutPage } from '../about/about';
/**
* Generated class for the UtilitiesPage page.
*
* See https://ionicframework.com/docs/components/#navigation for more info on
* Ionic pages and navigation.
*/
@Component({
selector: 'page-utilities',
templateUrl: 'utilities.html',
})
export class UtilitiesPage {
/**
* An instance of the JavaScript Math class required to use the floor function
*/
Math: Math = Math;
single_item = 1.0;
empty_bucket = 2.0;
filled_bucket = 10.0;
/**
* Determines what is the resulting weight value to be displayed. Handles invalid input values by returning
* appropriate validation messages
* @returns A string value that is displayed in the result card on the page
*/
hello = (() => {
if (!this.empty_bucket || !this.filled_bucket || !this.single_item) {
return 'Weight inputs cannot be empty';
}
if (this.empty_bucket <= 0 || this.filled_bucket <= 0 || this.single_item <= 0 ) {
return 'Weight value must be a positive value';
}
if (this.single_item - this.filled_bucket > 0) {
return 'Single item cannot weigh more than a filled bucket';
}
if (this.empty_bucket - this.filled_bucket >= 0) {
return 'Empty bucket cannot weigh more than a filled bucket';
}
return 'Total items: ' + Math.floor((this.filled_bucket - this.empty_bucket) / this.single_item);
});
/**
* @ignore
*/
constructor(public navCtrl: NavController, public navParams: NavParams,
public alertCtrl: AlertController, public modalCtrl : ModalController) {
}
/**
* Opens the About page modal
*/
openModal() {
var data = { message : 'hello world' };
var homePage = this.modalCtrl.create(AboutPage,data);
homePage.present();
}
/**
* @ignore
*/
ionViewDidLoad() {
console.log('ionViewDidLoad UtilitiesPage');
}
alertSing()
{
let alert = this.alertCtrl.create({
title: 'Instructions',
message:`
<ol>
<li>Weigh a single item and then enter the weight of the single item under "Weight Single Item"</li>
<li>Weigh the empty bucket and then enter the weight of the empty bucket under "Weight Empty Bucket"</li>
<li>Weigh the filled bucket which contains the items and then enter the weight of the filled bucket under "Weight Filled Bucket"</li>
</ol>`,
buttons: ['OK']
});
alert.present();
}
}
<!-- /**
* File Name: utilities.html
* Version Number: v1.1
* Author: Orisha Orrie
* Project Name: Ninshiki
* Organization: Software Sharks
* User Manual: Refer to https://github.com/OrishaOrrie/SoftwareSharks/blob/master/Documentation/User%20Manual.pdf
* Update History:
* ------------------------------------------
* Date Author Description
* 20/07/2018 Orisha Created component
* 18/09/2018 Orisha Fixed layout
* 18/09/2018 Orisha Added functionality
* ------------------------------------------
* Functional Description:
* The page to calculate the amount of items in a box.
*/ -->
<!--
Generated template for the UtilitiesPage page.
See http://ionicframework.com/docs/components/#navigation for more info on
Ionic pages and navigation.
-->
<ion-header>
<ion-navbar>
<ion-title>Item calculator</ion-title>
<ion-buttons end>
<button ion-button icon-only (click) ="alertSing()" >
<ion-icon name="information-circle" style="color: white"></ion-icon>
</button>
</ion-buttons>
<ion-buttons end>
<button ion-button icon-only (click) ="openModal()" >
<ion-icon name="help-circle" style="color: white"></ion-icon>
</button>
</ion-buttons>
</ion-navbar>
</ion-header>
<ion-content padding >
<h1 style="color: black; ">Calculate total items</h1>
<!--Values are entered here and validation occurs in the .ts file-->
<br>
<ion-card class = "inputFormat">
<ion-card-content>
<ion-item class="inputs">
<ion-label class="bob" stacked>Weight Single Item </ion-label>
<ion-input id="single" type="number" required placeholder="Single Item" [(ngModel)]="single_item" min=0></ion-input>
</ion-item>
</ion-card-content>
</ion-card>
<ion-card class = "inputFormat">
<ion-card-content>
<ion-item class = "inputs">
<ion-label class="bob" stacked>Weight Empty Bucket</ion-label>
<ion-input id="empty" type="number" required placeholder="Empty bucket" [(ngModel)]="empty_bucket" min=0></ion-input>
</ion-item>
</ion-card-content>
</ion-card>
<ion-card class = "inputFormat">
<ion-card-content>
<ion-item class = "inputs">
<ion-label class="bob" stacked>Weight Filled Bucket</ion-label>
<ion-input id="filled" type="number" required placeholder="Filled bucket" [(ngModel)]="filled_bucket" min=0></ion-input>
</ion-item>
</ion-card-content>
</ion-card>
<br>
<!--Card to display the results-->
<ion-card class = "result">
<ion-card-content class="result__amount">
{{ hello() }}
</ion-card-content>
</ion-card>
</ion-content>