Skip to content

Commit

Permalink
Merge pull request #248 from eneufeld/feat_fixUiBootstrap
Browse files Browse the repository at this point in the history
Fix broken directives due to angular ui bootstrap version bump
  • Loading branch information
edgarmueller committed May 2, 2016
2 parents 4ac3208 + efb23e5 commit 002d569
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 60 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
dist/
temp/
coverage/
reports/

# npm
node_modules/
Expand Down
2 changes: 1 addition & 1 deletion examples/app/local/local.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ angular.module('makeithappen').controller('LocalController', function() {
vm.data = {
name: 'John Doe',
vegetarian: false,
birthDate: "02.06.1985"
birthDate: "1985-06-02"
};
vm.users ={
"users":
Expand Down
37 changes: 25 additions & 12 deletions src/components/renderers/controls/datetime/datetime-directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ class DateTimeDirective implements ng.IDirective {
template = `
<jsonforms-control>
<div class="input-group">
<input type="text"
datepicker-popup="dd.MM.yyyy"
close-text="Close"
is-open="vm.isOpen"
id="{{vm.id}}"
class="form-control jsf-control-datetime"
ng-change='vm.modelChanged()'
ng-model="vm.modelValue[vm.fragment]"
<input type="text"
uib-datepicker-popup="dd.MM.yyyy"
close-text="Close"
is-open="vm.isOpen"
id="{{vm.id}}"
class="form-control jsf-control-datetime"
ng-change='vm.modelChanged()'
ng-model="vm.dt"
ng-model-options="{timezone:'UTC'}"
ng-readonly="vm.uiSchema.readOnly"/>
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="vm.openDate($event)">
<button type="button" class="btn btn-default" ng-click="vm.openDate()">
<i class="glyphicon glyphicon-calendar"></i>
</button>
</span>
Expand All @@ -32,14 +33,26 @@ interface DateTimeControllerScope extends ng.IScope {
class DateTimeController extends AbstractControl {
static $inject = ['$scope', 'PathResolver'];
private isOpen: boolean = false;
private dt: Date;
constructor(scope: DateTimeControllerScope, pathResolver: IPathResolver) {
super(scope, pathResolver);
let value = this.modelValue[this.fragment];
if (value) {
this.dt = new Date(value);
}
}
public openDate($event) {
$event.preventDefault();
$event.stopPropagation();
public openDate() {
this.isOpen = true;
}
protected modelChanged() {
if (this.dt != null) {
// returns a string in the form 'yyyy-mm-dd'
this.modelValue[this.fragment] = this.dt.toISOString().substr(0, 10);
} else {
this.modelValue[this.fragment] = null;
}
super.modelChanged();
}
}
const DateTimeControlRendererTester: RendererTester = function(element: IUISchemaElement,
dataSchema: any,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ class CategorizationDirective implements ng.IDirective {
<jsonforms-layout>
<div class="row">
<div class="col-sm-100">
<tabset>
<tab heading="{{category.label}}" ng-repeat="category in vm.uiSchema.elements">
<fieldset>
<jsonforms-inner ng-repeat="child in category.elements"
ui-schema="child" >
<uib-tabset>
<uib-tab
heading="{{category.label}}"
ng-repeat="category in vm.uiSchema.elements"
select="vm.changeSelectedCategory(category)">
<fieldset ng-if="vm.selectedCategory===category">
<jsonforms-inner ng-repeat="child in category.elements"
ui-schema="child" >
</jsonforms-inner>
</fieldset>
</tab>
</tabset>
</uib-tab>
</uib-tabset>
</div>
</div>
</jsonforms-layout>`;
Expand All @@ -28,9 +31,13 @@ interface CategorizationControllerScope extends ng.IScope {
}
class CategorizationController extends AbstractLayout {
static $inject = ['$scope'];
private selectedCategory;
constructor(scope: CategorizationControllerScope) {
super(scope);
}
public changeSelectedCategory(category) {
this.selectedCategory = category;
}
}
const CategorizationLayoutRendererTester: RendererTester = function(element: IUISchemaElement,
dataSchema: any,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ describe('Categorization', () => {
scope.data = { "name": "John Doe "};
let el = $compile('<jsonforms schema="schema" ui-schema="uiSchema" data="data"/>')(scope);
scope.$digest();
expect(el.html()).toContain("</tabset>"); //this is not resolved completly
expect(el.html()).toContain("</tab>"); //this is not resolved completly
expect(el.html()).toContain("</uib-tabset>"); //this is not resolved completly
expect(el.html()).toContain("</uib-tab>"); //this is not resolved completly
expect(el.html()).toContain('heading="Tab1"');
expect(el.html()).toContain('heading="MyTab2"');
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class MasterDetailDirective implements ng.IDirective {
template = `<div class="row">
<!-- Master -->
<div class="col-sm-30 jsf-masterdetail">
<jsonforms-masterdetail-collection properties="vm.subSchema.properties"
instance="vm.data"
<jsonforms-masterdetail-collection properties="vm.subSchema.properties"
instance="vm.data"
select="vm.select(child,childSchema)">
</jsonforms-masterdetail-collection>
</div>
<!-- Detail -->
<div class="col-sm-70">
<jsonforms schema="vm.selectedSchema"
data="vm.selectedChild"
<jsonforms schema="vm.selectedSchema"
data="vm.selectedChild"
ng-if="vm.selectedChild"></jsonforms>
</div>
</div>`;
Expand Down Expand Up @@ -62,51 +62,50 @@ class MasterDetailCollectionDirective implements ng.IDirective {
select: '&'
};
template = `<div>
<accordion close-others="false">
<accordion-group is-open="status_attribute.open"
ng-repeat="(key, value) in filter(properties)"
ng-class="{'jsf-masterdetail-empty':isEmptyInstance(key)}">
<accordion-heading class="jsf-masterdetail-header">
<span class="jsf-masterdetail-property">{{key}}</span>
<i class="pull-right glyphicon"
<uib-accordion close-others="false">
<uib-accordion-group is-open="status_attribute.open"
ng-repeat="(key, value) in filter(properties)"
class="{{isEmptyInstance(key)?'jsf-masterdetail-empty':''}}">
<uib-accordion-heading class="jsf-masterdetail-header">
<span class="jsf-masterdetail-property">{{key}}</span>
<i class="pull-right glyphicon"
ng-class="{
'glyphicon-chevron-down': status_attribute.open,
'glyphicon-chevron-down': status_attribute.open,
'glyphicon-chevron-right': !status_attribute.open
}"
}"
ng-show="!isEmptyInstance(key)">
</i>
</accordion-heading>
</uib-accordion-heading>
<accordion close-others="false"
<uib-accordion close-others="false"
ng-show="!isEmptyInstance(key)">
<accordion-group is-open="status_object.open"
ng-repeat="child in instance[key]"
ng-class="{'
jsf-masterdetail-empty':!hasKeys(value.items)
}">
<accordion-heading>
<span ng-click="selectElement(child,value)"
<uib-accordion-group
is-open="status_object.open"
ng-repeat="child in instance[key]"
class="{{!hasKeys(value.items)?'jsf-masterdetail-empty':''}}">
<uib-accordion-heading>
<span ng-click="selectElement(child,value)"
ng-class="{
'jsf-masterdetail-selected':selectedChild==child
}">
{{child.name!=undefined?child.name:child}}
</span>
<i class="pull-right glyphicon"
<i class="pull-right glyphicon"
ng-class="{
'glyphicon-chevron-down': status_object.open,
'glyphicon-chevron-down': status_object.open,
'glyphicon-chevron-right': !status_object.open
}"
}"
ng-if="hasKeys(value.items)"></i>
</accordion-heading>
<jsonforms-masterdetail-member filter='filter'
select='select'
child-schema="value.items"
child-data="child">
</uib-accordion-heading>
<jsonforms-masterdetail-member filter='filter'
select='select'
child-schema="value.items"
child-data="child">
</jsonforms-masterdetail-member>
</accordion-group>
</accordion>
</accordion-group>
</accordion>
</uib-accordion-group>
</uib-accordion>
</uib-accordion-group>
</uib-accordion>
</div>`;
link = (scope) => {
scope.filter = (properties) => {
Expand Down Expand Up @@ -147,9 +146,9 @@ class MasterDetailMember implements angular.IDirective {
link = (scope, element) => {
if (Object.keys(scope.filter(scope.childSchema.properties)).length !== 0) {
this.$compile(
`<jsonforms-masterdetail-collection
select="select"
properties="childSchema.properties"
`<jsonforms-masterdetail-collection
select="select"
properties="childSchema.properties"
instance="childData">
</jsonforms-masterdetail-collection>`
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('MasterDetail', () => {
let nameInput_empty = el[0].querySelector("#\\#\\/properties\\/name");
expect(nameInput_empty).toBeNull();

let x1 = el[0].querySelector("accordion accordion accordion-heading span");
let x1 = el[0].querySelector("uib-accordion uib-accordion uib-accordion-heading span");
angular.element(x1).triggerHandler("click");
expect(el.html()).toContain("<label");
let nameInput = el[0].querySelector("#\\#\\/properties\\/name");
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import pathResolver from './components/ng-services/pathresolver/pathresolver-ser
import '../jsf-bootstrap.css';

require('angular-ui-bootstrap');
require('angular-ui-bootstrap/dist/ui-bootstrap-csp.css');
require('angular-ui-validate');

angular.module('jsonforms', [
Expand Down

0 comments on commit 002d569

Please sign in to comment.