import {IdlService, IdlObject} from '@eg/core/idl.service';
import {PcrudService} from '@eg/core/pcrud.service';
import {OrgService} from '@eg/core/org.service';
+import { AuthService } from '@eg/core/auth.service';
+import { NetService } from '@eg/core/net.service';
+import { PoService } from '@eg/staff/acq/po/po.service';
export interface ComboboxEntry {
id: any;
}
@Directive({
- selector: 'ng-template[egIdlClass]'
+ selector: 'ng-template[egIdlClass]'
})
export class IdlClassTemplateDirective {
@Input() egIdlClass: string;
styles: [`
.icons {margin-left:-18px}
.material-icons {font-size: 16px;font-weight:bold}
+
+ .dropdown-item .text-bg-danger {
+ background-color: #f8d7da;
+ color: #58151c !important;
+ font-weight: 600;
+ padding: 0 1rem 0 .25rem;
+ }
+
+ .dropdown-item .text-bg-danger::before {
+ content: "\e160";
+ font-family: "Material Icons";
+ font-weight: normal;
+ vertical-align: sub;
+ }
+
+ .dropdown-item.active .text-bg-danger {
+ background-color: #f1aeb5;
+ }
+
+ .dropdown-item .text-bg-warning {
+ background-color: #ffe69c !important;
+ color: #723809;
+ font-weight: 600;
+ padding: 0 1rem 0 .25rem;
+ }
+
+ .dropdown-item .text-bg-warning::before {
+ content: "\e002";
+ font-family: "Material Icons";
+ font-weight: normal;
+ vertical-align: sub;
+ }
+
+ .dropdown-item.active .text-bg-warning {
+ background-color: #ffda6a;
+ }
`],
providers: [{
provide: NG_VALUE_ACCESSOR,
private idl: IdlService,
private pcrud: PcrudService,
private org: OrgService,
+ private net: NetService,
+ private auth: AuthService,
+ public poService: PoService
) {
this.entrylist = [];
this.asyncIds = {};
this.propagateTouch = fn;
}
+ acqfCheckFundBalance(fundId: number): any {
+ return this.net.request(
+ 'open-ils.acq',
+ 'open-ils.acq.fund.check_balance_percentages',
+ this.auth.token(), fundId
+ ).toPromise().then(r => {
+ if (r[0]) {
+ return 'danger';
+ } else if (r[1]) {
+ return 'warning';
+ } else {
+ return 'ok';
+ }
+ });
+ }
}
<eg-combobox idlClass="acqf" [selectedId]="charge.fund()"
(onChange)="charge.fund($event ? $event.id : null)"
i18n-placeholder placeholder="Fund..."
- [displayTemplate]="fundTmpl"
[asyncSupportsEmptyTermClick]="true"
[required]="true" [readOnly]="!charge.isnew() && !charge.ischanged()"
[idlQuerySort]="{acqf: 'year DESC, code'}"
(click)="removeCharge(charge)" *ngIf="canDelete(charge)" i18n>Remove</button>
</div>
</div>
-</ng-container>
-
-<!-- r.fm.id() makes sense in copy-attrs.component because there's a lot of setup there, but do we have the fund ID at all in this component?? -->
-<ng-template #fundTmpl let-r="result" i18n>
- <span id="eg-combobox-{{autoId}}-{{r.id}}" [ngClass]="{'text-bg-danger': checkFundBalance(r.fm.id()) === 'stop',
- 'text-bg-warning': checkFundBalance(r.fm.id()) === 'warning'}">{{r.label}}</span>
-</ng-template>
\ No newline at end of file
+</ng-container>
\ No newline at end of file
vertical-align: sub;
}
-.dropdown-item .text-bg-danger {
- background-color: #f8d7da;
- color: #58151c !important;
- font-weight: 600;
- padding: 0 1rem 0 .25rem;
-}
-
-.dropdown-item .text-bg-danger::before {
- content: "\e160";
- font-family: "Material Icons";
- font-weight: normal;
- vertical-align: sub;
-}
-
-.dropdown-item.active .text-bg-danger {
- background-color: #f1aeb5;
-}
-
-.dropdown-item .text-bg-warning {
- background-color: #ffe69c !important;
- color: #723809;
- font-weight: 600;
- padding: 0 1rem 0 .25rem;
-}
-
-.dropdown-item .text-bg-warning::before {
- content: "\e002";
- font-family: "Material Icons";
- font-weight: normal;
- vertical-align: sub;
-}
-
-.dropdown-item.active .text-bg-warning {
- background-color: #ffda6a;
-}
-