bastion 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.jshintrc +35 -0
- data/Gruntfile.js +24 -0
- data/LICENSE +339 -0
- data/README.md +8 -0
- data/Rakefile +53 -0
- data/app/assets/javascripts/bastion/auth/auth.module.js +87 -0
- data/app/assets/javascripts/bastion/auth/authorization.service.js +48 -0
- data/app/assets/javascripts/bastion/bastion-bootstrap.js +32 -0
- data/app/assets/javascripts/bastion/bastion-resource.factory.js +39 -0
- data/app/assets/javascripts/bastion/bastion.js +52 -0
- data/app/assets/javascripts/bastion/bastion.module.js +213 -0
- data/app/assets/javascripts/bastion/i18n/README +9 -0
- data/app/assets/javascripts/bastion/i18n/i18n.module.js +24 -0
- data/app/assets/javascripts/bastion/i18n/katello.pot +968 -0
- data/app/assets/javascripts/bastion/i18n/locale/README +1 -0
- data/app/assets/javascripts/bastion/i18n/translate.service.js +14 -0
- data/app/assets/javascripts/bastion/i18n/translations.js +3 -0
- data/app/assets/javascripts/bastion/i18n/zanata.xml +28 -0
- data/app/assets/javascripts/bastion/incubator/alch-alert.directive.js +67 -0
- data/app/assets/javascripts/bastion/incubator/alch-container-scroll.directive.js +44 -0
- data/app/assets/javascripts/bastion/incubator/alch-dropdown.directive.js +28 -0
- data/app/assets/javascripts/bastion/incubator/alch-edit.directive.js +361 -0
- data/app/assets/javascripts/bastion/incubator/alch-flyout.directive.js +19 -0
- data/app/assets/javascripts/bastion/incubator/alch-form-buttons.directive.js +60 -0
- data/app/assets/javascripts/bastion/incubator/alch-form-group.directive.js +87 -0
- data/app/assets/javascripts/bastion/incubator/alch-infinite-scroll.directive.js +84 -0
- data/app/assets/javascripts/bastion/incubator/alch-menu.directive.js +56 -0
- data/app/assets/javascripts/bastion/incubator/alch-modal.directive.js +80 -0
- data/app/assets/javascripts/bastion/incubator/alch-save-control.directive.js +42 -0
- data/app/assets/javascripts/bastion/incubator/alch-table.directive.js +295 -0
- data/app/assets/javascripts/bastion/incubator/format/alch-format.module.js +21 -0
- data/app/assets/javascripts/bastion/incubator/format/array-to-string.filter.js +30 -0
- data/app/assets/javascripts/bastion/incubator/format/boolean-to-yes-no.filter.js +34 -0
- data/app/assets/javascripts/bastion/incubator/format/capitalize.filter.js +32 -0
- data/app/assets/javascripts/bastion/incubator/format/key-value-to-string.filter.js +40 -0
- data/app/assets/javascripts/bastion/incubator/format/unlimitedFilter.filter.js +35 -0
- data/app/assets/javascripts/bastion/incubator/stylesheets/alch-edit.scss +34 -0
- data/app/assets/javascripts/bastion/incubator/stylesheets/header.scss +207 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-alert.html +6 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-dropdown.html +19 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-edit-add-item.html +21 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-edit-add-remove-cancel.html +28 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-edit-checkbox.html +6 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-edit-custom.html +8 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-edit-multiselect.html +17 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-edit-save-cancel.html +20 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-edit-select.html +10 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-edit-text.html +6 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-edit-textarea.html +6 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-edit.html +18 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-flyout.html +10 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-form-buttons.html +10 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-form-group.html +9 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-menu.html +18 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-modal-remove.html +13 -0
- data/app/assets/javascripts/bastion/incubator/views/alch-save-control.html +18 -0
- data/app/assets/javascripts/bastion/layouts/details-nutupane.html +73 -0
- data/app/assets/javascripts/bastion/layouts/nutupane.html +63 -0
- data/app/assets/javascripts/bastion/layouts/select-all-results.html +9 -0
- data/app/assets/javascripts/bastion/menu/menu-expander.service.js +51 -0
- data/app/assets/javascripts/bastion/menu/menu.module.js +26 -0
- data/app/assets/javascripts/bastion/utils/as.filter.js +33 -0
- data/app/assets/javascripts/bastion/utils/form-utils.service.js +53 -0
- data/app/assets/javascripts/bastion/utils/utils.module.js +21 -0
- data/app/assets/javascripts/bastion/widgets/current-tasks.directive.js +67 -0
- data/app/assets/javascripts/bastion/widgets/nutupane-table.directive.js +59 -0
- data/app/assets/javascripts/bastion/widgets/nutupane.factory.js +316 -0
- data/app/assets/javascripts/bastion/widgets/page-title.directive.js +61 -0
- data/app/assets/javascripts/bastion/widgets/page-title.service.js +42 -0
- data/app/assets/javascripts/bastion/widgets/path-selector.directive.js +109 -0
- data/app/assets/javascripts/bastion/widgets/views/current-tasks.html +23 -0
- data/app/assets/javascripts/bastion/widgets/views/path-selector.html +11 -0
- data/app/assets/javascripts/bastion/widgets/widgets.module.js +24 -0
- data/app/assets/stylesheets/bastion/animations.less +15 -0
- data/app/assets/stylesheets/bastion/bastion.less +160 -0
- data/app/assets/stylesheets/bastion/forms.less +41 -0
- data/app/assets/stylesheets/bastion/gpg-keys.less +36 -0
- data/app/assets/stylesheets/bastion/helpers.less +6 -0
- data/app/assets/stylesheets/bastion/mixins.less +15 -0
- data/app/assets/stylesheets/bastion/nutupane.less +382 -0
- data/app/assets/stylesheets/bastion/overrides.less +54 -0
- data/app/assets/stylesheets/bastion/path-selector.less +123 -0
- data/app/assets/stylesheets/bastion/systems.less +35 -0
- data/app/assets/stylesheets/bastion/tasks.less +23 -0
- data/app/assets/stylesheets/bastion/typography.less +31 -0
- data/app/assets/stylesheets/bastion/variables.less +3 -0
- data/app/controllers/bastion/bastion_controller.rb +24 -0
- data/app/views/bastion/layouts/application.html.erb +32 -0
- data/app/views/bastion/layouts/application_ie.html.erb +5 -0
- data/bastion.js +26 -0
- data/bower.json +94 -0
- data/config/routes.rb +25 -0
- data/config/routes/mount_engine.rb +3 -0
- data/grunt/bower.js +20 -0
- data/grunt/htmlhint.js +15 -0
- data/grunt/jshint.js +9 -0
- data/grunt/karma.js +83 -0
- data/lib/bastion.rb +17 -0
- data/lib/bastion/engine.rb +37 -0
- data/lib/bastion/version.rb +3 -0
- data/package.json +29 -0
- data/test/auth/authorization.service.test.js +63 -0
- data/test/bastion/bastion-resource.factory.test.js +31 -0
- data/test/bastion/test-constants.js +30 -0
- data/test/i18n/translate.service.test.js +31 -0
- data/test/incubator/alch-alert.directive.test.js +84 -0
- data/test/incubator/alch-container-scroll.directive.test.js +68 -0
- data/test/incubator/alch-dropdown.directive.test.js +113 -0
- data/test/incubator/alch-edit.directive.test.js +320 -0
- data/test/incubator/alch-flyout.directive.test.js +73 -0
- data/test/incubator/alch-form-buttons.directive.test.js +55 -0
- data/test/incubator/alch-form-group.directive.test.js +76 -0
- data/test/incubator/alch-infinite-scroll.directive.test.js +123 -0
- data/test/incubator/alch-menu.directive.test.js +94 -0
- data/test/incubator/alch-modal.directive.test.js +81 -0
- data/test/incubator/alch-table.directive.test.js +270 -0
- data/test/incubator/format/array-to-string.filter.test.js +38 -0
- data/test/incubator/format/boolean-to-yes-no.filter.test.js +41 -0
- data/test/incubator/format/capitalize.filter.test.js +35 -0
- data/test/incubator/format/key-value-to-string.filter.test.js +60 -0
- data/test/incubator/format/unlimited-filter.filter.test.js +31 -0
- data/test/incubator/nutupane-table.directive.test.js +69 -0
- data/test/incubator/nutupane.factory.test.js +307 -0
- data/test/menu/menu-expander.service.test.js +74 -0
- data/test/test-mocks.module.js +268 -0
- data/test/utils/as.filter.test.js +33 -0
- data/test/utils/form-utils.service.test.js +52 -0
- data/test/widgets/page-title.directive.test.js +54 -0
- data/test/widgets/page-title.service.test.js +51 -0
- data/test/widgets/path-selector.directive.test.js +136 -0
- data/vendor/assets/fonts/bastion/bootstrap/glyphicons-halflings-regular.eot +0 -0
- data/vendor/assets/fonts/bastion/bootstrap/glyphicons-halflings-regular.svg +229 -0
- data/vendor/assets/fonts/bastion/bootstrap/glyphicons-halflings-regular.ttf +0 -0
- data/vendor/assets/fonts/bastion/bootstrap/glyphicons-halflings-regular.woff +0 -0
- data/vendor/assets/fonts/bastion/font-awesome/FontAwesome.otf +0 -0
- data/vendor/assets/fonts/bastion/font-awesome/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/bastion/font-awesome/fontawesome-webfont.svg +399 -0
- data/vendor/assets/fonts/bastion/font-awesome/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/bastion/font-awesome/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Bold-webfont.eot +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Bold-webfont.svg +146 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Bold-webfont.ttf +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Bold-webfont.woff +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-BoldItalic-webfont.eot +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-BoldItalic-webfont.svg +146 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-BoldItalic-webfont.ttf +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-BoldItalic-webfont.woff +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-ExtraBold-webfont.eot +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-ExtraBold-webfont.svg +146 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-ExtraBold-webfont.ttf +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-ExtraBold-webfont.woff +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-ExtraBoldItalic-webfont.eot +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-ExtraBoldItalic-webfont.svg +146 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-ExtraBoldItalic-webfont.ttf +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-ExtraBoldItalic-webfont.woff +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Italic-webfont.eot +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Italic-webfont.svg +146 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Italic-webfont.ttf +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Italic-webfont.woff +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Light-webfont.eot +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Light-webfont.svg +146 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Light-webfont.ttf +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Light-webfont.woff +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-LightItalic-webfont.eot +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-LightItalic-webfont.svg +146 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-LightItalic-webfont.ttf +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-LightItalic-webfont.woff +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Regular-webfont.eot +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Regular-webfont.svg +146 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Regular-webfont.ttf +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Regular-webfont.woff +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Semibold-webfont.eot +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Semibold-webfont.svg +146 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Semibold-webfont.ttf +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-Semibold-webfont.woff +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-SemiboldItalic-webfont.eot +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-SemiboldItalic-webfont.svg +146 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-SemiboldItalic-webfont.ttf +0 -0
- data/vendor/assets/fonts/bastion/rcue/OpenSans-SemiboldItalic-webfont.woff +0 -0
- data/vendor/assets/fonts/bastion/rcue/Overpass-Bold-webfont.eot +0 -0
- data/vendor/assets/fonts/bastion/rcue/Overpass-Bold-webfont.svg +454 -0
- data/vendor/assets/fonts/bastion/rcue/Overpass-Bold-webfont.ttf +0 -0
- data/vendor/assets/fonts/bastion/rcue/Overpass-Bold-webfont.woff +0 -0
- data/vendor/assets/fonts/bastion/rcue/Overpass-Regular-webfont.eot +0 -0
- data/vendor/assets/fonts/bastion/rcue/Overpass-Regular-webfont.svg +454 -0
- data/vendor/assets/fonts/bastion/rcue/Overpass-Regular-webfont.ttf +0 -0
- data/vendor/assets/fonts/bastion/rcue/Overpass-Regular-webfont.woff +0 -0
- data/vendor/assets/javascripts/bastion/alchemy/alchemy.js +20 -0
- data/vendor/assets/javascripts/bastion/angular-animate/angular-animate.js +1226 -0
- data/vendor/assets/javascripts/bastion/angular-blocks/angular-blocks.js +79 -0
- data/vendor/assets/javascripts/bastion/angular-bootstrap/ui-bootstrap-tpls.js +3677 -0
- data/vendor/assets/javascripts/bastion/angular-bootstrap/ui-bootstrap.js +3427 -0
- data/vendor/assets/javascripts/bastion/angular-gettext/angular-gettext.js +345 -0
- data/vendor/assets/javascripts/bastion/angular-resource/angular-resource.js +594 -0
- data/vendor/assets/javascripts/bastion/angular-route/angular-route.js +920 -0
- data/vendor/assets/javascripts/bastion/angular-sanitize/angular-sanitize.js +622 -0
- data/vendor/assets/javascripts/bastion/angular-ui-bootstrap/datepicker.js +447 -0
- data/vendor/assets/javascripts/bastion/angular-ui-bootstrap/timepicker.js +232 -0
- data/vendor/assets/javascripts/bastion/angular-ui-router/angular-ui-router.js +3223 -0
- data/vendor/assets/javascripts/bastion/angular-uuid4/angular-uuid4.js +21 -0
- data/vendor/assets/javascripts/bastion/angular/angular.js +20560 -0
- data/vendor/assets/javascripts/bastion/es5-shim/es5-shim.js +1216 -0
- data/vendor/assets/javascripts/bastion/json3/json3.js +861 -0
- data/vendor/assets/javascripts/bastion/ngUpload/ng-upload.js +205 -0
- data/vendor/assets/javascripts/bastion/underscore/underscore.js +1276 -0
- data/vendor/assets/stylesheets/bastion/alchemy/_colors.scss +99 -0
- data/vendor/assets/stylesheets/bastion/alchemy/_media_object.scss +22 -0
- data/vendor/assets/stylesheets/bastion/alchemy/_mixins.scss +24 -0
- data/vendor/assets/stylesheets/bastion/alchemy/_normalize.scss +396 -0
- data/vendor/assets/stylesheets/bastion/alchemy/_vars.scss +31 -0
- data/vendor/assets/stylesheets/bastion/alchemy/alchemy.scss +8 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/alerts.less +67 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/badges.less +51 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/bootstrap.less +49 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/breadcrumbs.less +23 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/button-groups.less +227 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/buttons.less +155 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/carousel.less +232 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/close.less +33 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/code.less +53 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/component-animations.less +29 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/dropdowns.less +187 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/forms.less +375 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/glyphicons.less +237 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/grid.less +79 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/input-groups.less +136 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/jumbotron.less +46 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/labels.less +64 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/list-group.less +88 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/media.less +56 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/mixins.less +845 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/modals.less +129 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/navbar.less +612 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/navs.less +242 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/normalize.less +406 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/pager.less +55 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/pagination.less +85 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/panels.less +182 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/popovers.less +133 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/print.less +105 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/progress-bars.less +80 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/responsive-utilities.less +209 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/scaffolding.less +119 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/tables.less +231 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/theme.less +247 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/thumbnails.less +36 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/tooltip.less +95 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/type.less +281 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/utilities.less +56 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/variables.less +642 -0
- data/vendor/assets/stylesheets/bastion/bootstrap/wells.less +29 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/less/bootstrap.less +84 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/less/core.less +129 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/less/extras.less +93 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/less/font-awesome-ie7.less +1953 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/less/font-awesome.less +33 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/less/icons.less +381 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/less/mixins.less +48 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/less/path.less +14 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/less/variables.less +735 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/scss/_bootstrap.scss +84 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/scss/_core.scss +129 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/scss/_extras.scss +93 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/scss/_icons.scss +381 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/scss/_mixins.scss +48 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/scss/_path.scss +14 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/scss/_variables.scss +734 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/scss/font-awesome-ie7.scss +1953 -0
- data/vendor/assets/stylesheets/bastion/font-awesome/scss/font-awesome.scss +33 -0
- data/vendor/assets/stylesheets/bastion/rcue/buttons.less +44 -0
- data/vendor/assets/stylesheets/bastion/rcue/fonts.less +52 -0
- data/vendor/assets/stylesheets/bastion/rcue/forms.less +19 -0
- data/vendor/assets/stylesheets/bastion/rcue/mixins.less +50 -0
- data/vendor/assets/stylesheets/bastion/rcue/navbar.less +481 -0
- data/vendor/assets/stylesheets/bastion/rcue/rcue.less +15 -0
- data/vendor/assets/stylesheets/bastion/rcue/variables.less +47 -0
- metadata +376 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* @ngdoc directive
|
3
|
+
* @name alchemy.directive:alchFlyout
|
4
|
+
* @restrict EA
|
5
|
+
*
|
6
|
+
* @description
|
7
|
+
* Provides a "flyout" sub-menu for menu items with one or more
|
8
|
+
* child menu items.
|
9
|
+
*/
|
10
|
+
angular.module('alchemy').directive('alchFlyout', function () {
|
11
|
+
return {
|
12
|
+
restrict: 'EA',
|
13
|
+
replace: true,
|
14
|
+
scope: {
|
15
|
+
'flyout' : '=alchFlyout'
|
16
|
+
},
|
17
|
+
templateUrl: 'incubator/views/alch-flyout.html'
|
18
|
+
};
|
19
|
+
});
|
@@ -0,0 +1,60 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright 2014 Red Hat, Inc.
|
3
|
+
*
|
4
|
+
* This software is licensed to you under the GNU General Public
|
5
|
+
* License as published by the Free Software Foundation; either version
|
6
|
+
* 2 of the License (GPLv2) or (at your option) any later version.
|
7
|
+
* There is NO WARRANTY for this software, express or implied,
|
8
|
+
* including the implied warranties of MERCHANTABILITY,
|
9
|
+
* NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
10
|
+
* have received a copy of GPLv2 along with this software; if not, see
|
11
|
+
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
12
|
+
*/
|
13
|
+
|
14
|
+
/**
|
15
|
+
* @ngdoc directive
|
16
|
+
* @name alchemy.directive:alchFormButtons
|
17
|
+
*
|
18
|
+
* @description
|
19
|
+
* Encapsulates the standard structure and styling for create and cancel buttons
|
20
|
+
* when used with a form.
|
21
|
+
*
|
22
|
+
* @example
|
23
|
+
* <div alch-form-buttons
|
24
|
+
on-cancel="transitionTo('product.index')"
|
25
|
+
on-save="save(product)"
|
26
|
+
working="working">
|
27
|
+
</div>
|
28
|
+
*/
|
29
|
+
angular.module('alchemy').directive('alchFormButtons', function () {
|
30
|
+
return {
|
31
|
+
replace: true,
|
32
|
+
require: '^form',
|
33
|
+
templateUrl: 'incubator/views/alch-form-buttons.html',
|
34
|
+
scope: {
|
35
|
+
handleCancel: '&onCancel',
|
36
|
+
handleSave: '&onSave',
|
37
|
+
working: '='
|
38
|
+
},
|
39
|
+
link: function (scope, iElement, iAttrs, controller) {
|
40
|
+
|
41
|
+
if (scope.working === undefined) {
|
42
|
+
scope.working = false;
|
43
|
+
}
|
44
|
+
|
45
|
+
scope.isInvalid = function () {
|
46
|
+
var invalid = controller.$invalid;
|
47
|
+
|
48
|
+
angular.forEach(controller, function (value) {
|
49
|
+
if (value && value.$error) {
|
50
|
+
if (value.$error.server) {
|
51
|
+
invalid = false;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
});
|
55
|
+
|
56
|
+
return invalid;
|
57
|
+
};
|
58
|
+
}
|
59
|
+
};
|
60
|
+
});
|
@@ -0,0 +1,87 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright 2014 Red Hat, Inc.
|
3
|
+
*
|
4
|
+
* This software is licensed to you under the GNU General Public
|
5
|
+
* License as published by the Free Software Foundation; either version
|
6
|
+
* 2 of the License (GPLv2) or (at your option) any later version.
|
7
|
+
* There is NO WARRANTY for this software, express or implied,
|
8
|
+
* including the implied warranties of MERCHANTABILITY,
|
9
|
+
* NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
10
|
+
* have received a copy of GPLv2 along with this software; if not, see
|
11
|
+
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
12
|
+
*/
|
13
|
+
|
14
|
+
/**
|
15
|
+
* @ngdoc directive
|
16
|
+
* @name alchemy.directive:alchFormGroup
|
17
|
+
*
|
18
|
+
* @description
|
19
|
+
* Encapsulates the structure and styling for a label + input used within a
|
20
|
+
* Bootstrap3 based form.
|
21
|
+
*
|
22
|
+
* @example
|
23
|
+
* <div alch-form-group label="{{ 'Name' | translate }}" required>
|
24
|
+
<input id="name"
|
25
|
+
name="name"
|
26
|
+
ng-model="product.name"
|
27
|
+
type="text"
|
28
|
+
tabindex="1"
|
29
|
+
required/>
|
30
|
+
</div>
|
31
|
+
*/
|
32
|
+
angular.module('alchemy').directive('alchFormGroup', function () {
|
33
|
+
function getInput(element) {
|
34
|
+
// table is used for bootstrap3 date/time pickers
|
35
|
+
var input = element.find('table');
|
36
|
+
|
37
|
+
if (input.length === 0) {
|
38
|
+
input = element.find('input');
|
39
|
+
|
40
|
+
if (input.length === 0) {
|
41
|
+
input = element.find('select');
|
42
|
+
|
43
|
+
if (input.length === 0) {
|
44
|
+
input = element.find('textarea');
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
return input;
|
49
|
+
}
|
50
|
+
|
51
|
+
return {
|
52
|
+
transclude: true,
|
53
|
+
replace: true,
|
54
|
+
require: '^form',
|
55
|
+
templateUrl: 'incubator/views/alch-form-group.html',
|
56
|
+
scope: {
|
57
|
+
'label': '@',
|
58
|
+
'field': '@'
|
59
|
+
},
|
60
|
+
link: function (scope, iElement, iAttrs, controller) {
|
61
|
+
var input = getInput(iElement),
|
62
|
+
type = input.attr('type'),
|
63
|
+
field;
|
64
|
+
|
65
|
+
if (!scope.field) {
|
66
|
+
scope.field = input.attr('id');
|
67
|
+
}
|
68
|
+
field = scope.field;
|
69
|
+
|
70
|
+
if (['checkbox', 'radio', 'time'].indexOf(type) === -1) {
|
71
|
+
input.addClass('form-control');
|
72
|
+
}
|
73
|
+
|
74
|
+
if (input.attr('required')) {
|
75
|
+
iElement.addClass('required');
|
76
|
+
}
|
77
|
+
|
78
|
+
if (controller[field]) {
|
79
|
+
scope.error = controller[field].$error;
|
80
|
+
}
|
81
|
+
|
82
|
+
scope.hasErrors = function () {
|
83
|
+
return controller[field] && controller[field].$invalid && controller[field].$dirty;
|
84
|
+
};
|
85
|
+
}
|
86
|
+
};
|
87
|
+
});
|
@@ -0,0 +1,84 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright 2014 Red Hat, Inc.
|
3
|
+
*
|
4
|
+
* This software is licensed to you under the GNU General Public
|
5
|
+
* License as published by the Free Software Foundation; either version
|
6
|
+
* 2 of the License (GPLv2) or (at your option) any later version.
|
7
|
+
* There is NO WARRANTY for this software, express or implied,
|
8
|
+
* including the implied warranties of MERCHANTABILITY,
|
9
|
+
* NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
10
|
+
* have received a copy of GPLv2 along with this software; if not, see
|
11
|
+
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
12
|
+
*/
|
13
|
+
|
14
|
+
/**
|
15
|
+
* @ngdoc directive
|
16
|
+
* @name alchemy.directive:alchInfiniteScroll
|
17
|
+
*
|
18
|
+
* @description
|
19
|
+
* The infinite scroll directive should be applied to a wrapping div around another element
|
20
|
+
* and provides automatic loading when a user scrolls to the bottom of the element.
|
21
|
+
*
|
22
|
+
* Note that the element using the alch-infinite-scroll directive should have it's overflow
|
23
|
+
* set properly.
|
24
|
+
*
|
25
|
+
* @example
|
26
|
+
* <pre>
|
27
|
+
* <div alch-infinite-scroll="loadMore()" style="height: 100px; overflow-y: auto;">
|
28
|
+
* <p style="height: 1000px;">Hello</p>
|
29
|
+
* </div>
|
30
|
+
* </pre>
|
31
|
+
*/
|
32
|
+
angular.module('alchemy').directive('alchInfiniteScroll', [function () {
|
33
|
+
return {
|
34
|
+
scope: {
|
35
|
+
data: '=',
|
36
|
+
loadMoreFunction: '&alchInfiniteScroll',
|
37
|
+
skipInitialLoad: '='
|
38
|
+
},
|
39
|
+
controller: function ($scope, $element) {
|
40
|
+
|
41
|
+
var result, raw = $element[0];
|
42
|
+
|
43
|
+
$element.bind('scroll', function () {
|
44
|
+
var sliderPosition = raw.scrollTop + raw.offsetHeight;
|
45
|
+
if (sliderPosition > 0 && sliderPosition >= raw.scrollHeight - 1) {
|
46
|
+
$scope.loadMoreFunction();
|
47
|
+
}
|
48
|
+
});
|
49
|
+
|
50
|
+
var getScrollHeight = function () {
|
51
|
+
var scrollHeight = 0;
|
52
|
+
$element.children().each(function () {
|
53
|
+
scrollHeight = scrollHeight + $(this).get(0).scrollHeight;
|
54
|
+
});
|
55
|
+
return scrollHeight;
|
56
|
+
};
|
57
|
+
|
58
|
+
var isPromise = function (promise) {
|
59
|
+
return promise && promise.hasOwnProperty('then');
|
60
|
+
};
|
61
|
+
|
62
|
+
var loadUntilScroll = function () {
|
63
|
+
var result;
|
64
|
+
if (getScrollHeight() < $element.height()) {
|
65
|
+
result = $scope.loadMoreFunction();
|
66
|
+
if (isPromise(result)) {
|
67
|
+
result.then(function () {
|
68
|
+
if (getScrollHeight() < $element.height()) {
|
69
|
+
loadUntilScroll();
|
70
|
+
}
|
71
|
+
});
|
72
|
+
}
|
73
|
+
}
|
74
|
+
};
|
75
|
+
|
76
|
+
if (!$scope.skipInitialLoad && ($scope.data === undefined || $scope.data.length === 0)) {
|
77
|
+
result = $scope.loadMoreFunction();
|
78
|
+
if (isPromise(result)) {
|
79
|
+
result.then(loadUntilScroll);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
};
|
84
|
+
}]);
|
@@ -0,0 +1,56 @@
|
|
1
|
+
/**
|
2
|
+
* @ngdoc directive
|
3
|
+
* @name alchemy.directive:alchMenu
|
4
|
+
* @restrict EA
|
5
|
+
* @requires $window
|
6
|
+
*
|
7
|
+
* @description
|
8
|
+
* Provides a menu.
|
9
|
+
*/
|
10
|
+
angular.module('alchemy').directive('alchMenu', ['$window', function ($window) {
|
11
|
+
return {
|
12
|
+
restrict: 'EA',
|
13
|
+
replace: true,
|
14
|
+
scope: {
|
15
|
+
'menu': '=alchMenu',
|
16
|
+
'compact' : '@'
|
17
|
+
},
|
18
|
+
templateUrl: 'incubator/views/alch-menu.html',
|
19
|
+
controller: ['$scope', function ($scope) {
|
20
|
+
$scope.dropdown = {};
|
21
|
+
|
22
|
+
$scope.handleHover = function (item, mousein) {
|
23
|
+
if (item.type === 'dropdown' && mousein) {
|
24
|
+
item.active = true;
|
25
|
+
$scope.dropdown = item.items;
|
26
|
+
$scope.dropdown.show = true;
|
27
|
+
$scope.dropdown.direction = $scope.menu.location;
|
28
|
+
} else {
|
29
|
+
$scope.dropdown.show = false;
|
30
|
+
|
31
|
+
if (item !== $scope.menu.activeItem) {
|
32
|
+
item.active = false;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
37
|
+
}],
|
38
|
+
link: function (scope, element, attrs) {
|
39
|
+
var elementOriginalOffset;
|
40
|
+
|
41
|
+
if (attrs.compact !== undefined) {
|
42
|
+
elementOriginalOffset = $(element).offset().top;
|
43
|
+
|
44
|
+
angular.element($window).bind('scroll', function () {
|
45
|
+
var windowScrollTop = $($window).scrollTop();
|
46
|
+
|
47
|
+
if (windowScrollTop > elementOriginalOffset + 2) {
|
48
|
+
element.parent().addClass('compact');
|
49
|
+
} else if (windowScrollTop < elementOriginalOffset) {
|
50
|
+
element.parent().removeClass('compact');
|
51
|
+
}
|
52
|
+
});
|
53
|
+
}
|
54
|
+
}
|
55
|
+
};
|
56
|
+
}]);
|
@@ -0,0 +1,80 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright 2014 Red Hat, Inc.
|
3
|
+
*
|
4
|
+
* This software is licensed to you under the GNU General Public
|
5
|
+
* License as published by the Free Software Foundation; either version
|
6
|
+
* 2 of the License (GPLv2) or (at your option) any later version.
|
7
|
+
* There is NO WARRANTY for this software, express or implied,
|
8
|
+
* including the implied warranties of MERCHANTABILITY,
|
9
|
+
* NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
10
|
+
* have received a copy of GPLv2 along with this software; if not, see
|
11
|
+
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
12
|
+
*/
|
13
|
+
|
14
|
+
/**
|
15
|
+
* @ngdoc directive
|
16
|
+
* @name alchemy.directive:alchConfirm
|
17
|
+
* @restrict A
|
18
|
+
*
|
19
|
+
* @requires $templateCache
|
20
|
+
* @requires $modal
|
21
|
+
*
|
22
|
+
* @description
|
23
|
+
* Provides a wrapper around angular-ui's modal dialog service.
|
24
|
+
*/
|
25
|
+
angular.module('alchemy').directive('alchModal',
|
26
|
+
['$templateCache', '$modal', function ($templateCache, $modal) {
|
27
|
+
return {
|
28
|
+
// To be expanded when we add additional type of modals
|
29
|
+
templateUrl: 'incubator/views/alch-modal-remove.html',
|
30
|
+
replace: true,
|
31
|
+
scope: {
|
32
|
+
action: '&alchModal',
|
33
|
+
modelName: '@model',
|
34
|
+
model: '=',
|
35
|
+
modalHeader: '@',
|
36
|
+
modalBody: '@'
|
37
|
+
},
|
38
|
+
compile: function (element) {
|
39
|
+
return function (scope) {
|
40
|
+
var modalInstance, modalController, modalId;
|
41
|
+
|
42
|
+
modalId = 'alchModal%d.html'.replace('%d', Math.random().toString());
|
43
|
+
|
44
|
+
modalController = ['$scope', '$modalInstance', 'model', function ($scope, $modalInstance, model) {
|
45
|
+
$scope[scope.modelName] = model;
|
46
|
+
$scope['modalHeader'] = scope.modalHeader;
|
47
|
+
$scope['modalBody'] = scope.modalBody;
|
48
|
+
|
49
|
+
$scope.ok = function () {
|
50
|
+
$modalInstance.close();
|
51
|
+
};
|
52
|
+
|
53
|
+
$scope.cancel = function () {
|
54
|
+
$modalInstance.dismiss('cancel');
|
55
|
+
};
|
56
|
+
}];
|
57
|
+
|
58
|
+
scope.openModal = function () {
|
59
|
+
modalInstance = $modal.open({
|
60
|
+
templateUrl: modalId,
|
61
|
+
controller: modalController,
|
62
|
+
resolve: {
|
63
|
+
model: function () {
|
64
|
+
return scope[scope.modelName];
|
65
|
+
}
|
66
|
+
}
|
67
|
+
});
|
68
|
+
|
69
|
+
modalInstance.result.then(function () {
|
70
|
+
scope.action();
|
71
|
+
});
|
72
|
+
};
|
73
|
+
|
74
|
+
scope.$parent.openModal = scope.openModal;
|
75
|
+
|
76
|
+
$templateCache.put(modalId, element.html());
|
77
|
+
};
|
78
|
+
}
|
79
|
+
};
|
80
|
+
}]);
|
@@ -0,0 +1,42 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright 2014 Red Hat, Inc.
|
3
|
+
*
|
4
|
+
* This software is licensed to you under the GNU General Public
|
5
|
+
* License as published by the Free Software Foundation; either version
|
6
|
+
* 2 of the License (GPLv2) or (at your option) any later version.
|
7
|
+
* There is NO WARRANTY for this software, express or implied,
|
8
|
+
* including the implied warranties of MERCHANTABILITY,
|
9
|
+
* NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
10
|
+
* have received a copy of GPLv2 along with this software; if not, see
|
11
|
+
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
12
|
+
**/
|
13
|
+
|
14
|
+
/**
|
15
|
+
* @ngdoc directive
|
16
|
+
* @name alchemy.directive:alchSaveButton
|
17
|
+
*
|
18
|
+
* @description
|
19
|
+
* Simple directive for encapsulating create and cancel buttons. This includes states
|
20
|
+
* for disabling buttons and setting a visual working state.
|
21
|
+
*
|
22
|
+
* @example
|
23
|
+
* <pre>
|
24
|
+
* <div alch-save-control
|
25
|
+
* on-cancel="closeItem()"
|
26
|
+
* on-save="save(product)"
|
27
|
+
* invalid="productForm.$invalid">
|
28
|
+
* </div>
|
29
|
+
*/
|
30
|
+
angular.module('alchemy').directive('alchSaveControl', function () {
|
31
|
+
return {
|
32
|
+
restrict: 'AE',
|
33
|
+
replace: true,
|
34
|
+
templateUrl: 'incubator/views/alch-save-control.html',
|
35
|
+
scope: {
|
36
|
+
handleSave: '&onSave',
|
37
|
+
handleCancel: '&onCancel',
|
38
|
+
invalid: '=',
|
39
|
+
working: '='
|
40
|
+
}
|
41
|
+
};
|
42
|
+
});
|
@@ -0,0 +1,295 @@
|
|
1
|
+
/**
|
2
|
+
* @ngdoc directive
|
3
|
+
* @name alchemy.directive:alchTable
|
4
|
+
* @restrict A
|
5
|
+
*
|
6
|
+
* @description
|
7
|
+
*
|
8
|
+
* @example
|
9
|
+
*/
|
10
|
+
angular.module('alchemy')
|
11
|
+
.directive('alchTable', [function () {
|
12
|
+
return {
|
13
|
+
restrict: 'A',
|
14
|
+
replace: true,
|
15
|
+
scope: {
|
16
|
+
'table': '=alchTable',
|
17
|
+
'rowSelect': '@',
|
18
|
+
'rowChoice': '@'
|
19
|
+
},
|
20
|
+
controller: 'AlchTableController'
|
21
|
+
};
|
22
|
+
}])
|
23
|
+
.controller('AlchTableController', ['$scope', function ($scope) {
|
24
|
+
var rows = $scope.rows = [],
|
25
|
+
headers = $scope.headers = [],
|
26
|
+
self = this;
|
27
|
+
|
28
|
+
this.selection = {allSelected: false, selectAllDisabled: false};
|
29
|
+
|
30
|
+
$scope.table.numSelected = 0;
|
31
|
+
$scope.table.chosenRow = null;
|
32
|
+
|
33
|
+
$scope.table.getSelected = function () {
|
34
|
+
var selectedRows = [];
|
35
|
+
angular.forEach($scope.table.rows, function (row, rowIndex) {
|
36
|
+
if (row.selected === true) {
|
37
|
+
selectedRows.push($scope.table.rows[rowIndex]);
|
38
|
+
}
|
39
|
+
});
|
40
|
+
return selectedRows;
|
41
|
+
};
|
42
|
+
|
43
|
+
$scope.table.selectAllDisabled = false;
|
44
|
+
|
45
|
+
this.disableSelectAll = $scope.table.disableSelectAll = function () {
|
46
|
+
self.selection.selectAllDisabled = true;
|
47
|
+
};
|
48
|
+
|
49
|
+
this.enableSelectAll = $scope.table.enableSelectAll = function () {
|
50
|
+
self.selection.selectAllDisabled = false;
|
51
|
+
};
|
52
|
+
|
53
|
+
$scope.table.allSelected = function () {
|
54
|
+
return self.selection.allSelected;
|
55
|
+
};
|
56
|
+
|
57
|
+
this.addRow = function (row) {
|
58
|
+
rows.push(row);
|
59
|
+
|
60
|
+
if (headers.length) {
|
61
|
+
angular.forEach(headers[0].columns, function (column, columnIndex) {
|
62
|
+
if (row.cells[columnIndex]) {
|
63
|
+
row.cells[columnIndex].show = column.show;
|
64
|
+
}
|
65
|
+
});
|
66
|
+
}
|
67
|
+
};
|
68
|
+
|
69
|
+
this.addHeader = function (columns) {
|
70
|
+
headers.push(columns);
|
71
|
+
};
|
72
|
+
|
73
|
+
this.itemSelected = function (row) {
|
74
|
+
$scope.table.numSelected += row.selected ? 1 : -1;
|
75
|
+
self.selection.allSelected = false;
|
76
|
+
};
|
77
|
+
|
78
|
+
this.itemChosen = function (row) {
|
79
|
+
$scope.table.chosenRow = row;
|
80
|
+
};
|
81
|
+
|
82
|
+
this.selectAll = $scope.table.selectAll = function (selected) {
|
83
|
+
var table = $scope.table,
|
84
|
+
rowsSelected = 0;
|
85
|
+
|
86
|
+
self.selection.allSelected = selected;
|
87
|
+
angular.forEach(table.rows, function (row) {
|
88
|
+
if (!row.unselectable) {
|
89
|
+
row.selected = self.selection.allSelected;
|
90
|
+
rowsSelected = rowsSelected + 1;
|
91
|
+
}
|
92
|
+
});
|
93
|
+
$scope.table.numSelected = selected ? rowsSelected : 0;
|
94
|
+
};
|
95
|
+
|
96
|
+
}])
|
97
|
+
.directive('alchTableHead', [function () {
|
98
|
+
var rowSelectTemplate = function () {
|
99
|
+
return '<th class="row-select">' +
|
100
|
+
'<input type="checkbox"' +
|
101
|
+
'ng-model="selection.allSelected"' +
|
102
|
+
'ng-disabled="selection.selectAllDisabled"' +
|
103
|
+
'ng-change="allSelected()">' +
|
104
|
+
'</th>';
|
105
|
+
}, rowChoiceTemplate = function () {
|
106
|
+
return '<th translate class="row-select"></th>';
|
107
|
+
};
|
108
|
+
|
109
|
+
return {
|
110
|
+
require: '^alchTable',
|
111
|
+
restrict: 'A',
|
112
|
+
scope: true,
|
113
|
+
controller: 'AlchTableHeadController',
|
114
|
+
compile: function (tElement, tAttrs) {
|
115
|
+
if (tAttrs.rowSelect !== undefined) {
|
116
|
+
tElement.prepend(rowSelectTemplate());
|
117
|
+
} else if (tAttrs.rowChoice !== undefined) {
|
118
|
+
tElement.prepend(rowChoiceTemplate());
|
119
|
+
}
|
120
|
+
|
121
|
+
return function (scope, element, attrs, alchTableController) {
|
122
|
+
if (tAttrs.rowSelect !== undefined) {
|
123
|
+
scope.table.rowSelect = true;
|
124
|
+
} else if (tAttrs.rowChoice !== undefined) {
|
125
|
+
scope.table.rowChoice = true;
|
126
|
+
}
|
127
|
+
|
128
|
+
alchTableController.addHeader(scope.header);
|
129
|
+
|
130
|
+
scope.selection = alchTableController.selection;
|
131
|
+
|
132
|
+
scope.allSelected = function () {
|
133
|
+
alchTableController.selectAll(scope.selection.allSelected);
|
134
|
+
};
|
135
|
+
};
|
136
|
+
}
|
137
|
+
};
|
138
|
+
}])
|
139
|
+
.controller('AlchTableHeadController', ['$scope', function ($scope) {
|
140
|
+
$scope.header = {
|
141
|
+
columns: []
|
142
|
+
};
|
143
|
+
|
144
|
+
this.addColumn = function (column) {
|
145
|
+
$scope.header.columns.push(column);
|
146
|
+
};
|
147
|
+
}])
|
148
|
+
.directive('alchTableColumn', ['$compile', function ($compile) {
|
149
|
+
var sortIconTemplate = '<th ng-click="table.sortBy(column)">' +
|
150
|
+
'<i class="sort-icon" ng-show="table.resource.sort.by == column.id" ng-class="{\'icon-sort-down\': column.sortOrder == \'DESC\', \'icon-sort-up\': column.sortOrder == \'ASC\'}"></i>' +
|
151
|
+
'</th>';
|
152
|
+
return {
|
153
|
+
require: '^alchTableHead',
|
154
|
+
restrict: 'A',
|
155
|
+
scope: true,
|
156
|
+
controller: ['$scope', function ($scope) {
|
157
|
+
$scope.column = { show: true };
|
158
|
+
}],
|
159
|
+
compile: function (element, attributes) {
|
160
|
+
if (attributes.hasOwnProperty("sortable")) {
|
161
|
+
var newElement = angular.element(sortIconTemplate);
|
162
|
+
newElement.find('.sort-icon').before(element.html());
|
163
|
+
newElement.addClass('sortable');
|
164
|
+
newElement.addClass(element.attr('class'));
|
165
|
+
element.replaceWith(newElement);
|
166
|
+
}
|
167
|
+
return function (scope, element, attributes, alchTableHeadController) {
|
168
|
+
if (attributes.hasOwnProperty("sortable")) {
|
169
|
+
$compile(element)(scope);
|
170
|
+
}
|
171
|
+
scope.column.id = attributes["alchTableColumn"];
|
172
|
+
alchTableHeadController.addColumn(scope.column);
|
173
|
+
|
174
|
+
scope.$watch('column.show', function (show) {
|
175
|
+
var display = show ? '' : 'none';
|
176
|
+
element.css('display', display);
|
177
|
+
});
|
178
|
+
};
|
179
|
+
}
|
180
|
+
};
|
181
|
+
}])
|
182
|
+
.directive('alchTableRow', ['$parse', function ($parse) {
|
183
|
+
var rowSelectTemplate, rowChoiceTemplate, activeRowTemplate;
|
184
|
+
|
185
|
+
rowSelectTemplate = function (model) {
|
186
|
+
return '<td class="row-select">' +
|
187
|
+
'<input type="checkbox"' +
|
188
|
+
'ng-model="' + model + '.selected"' +
|
189
|
+
'ng-disabled="' + model + '.unselectable"' +
|
190
|
+
'ng-change="itemSelected(' + model + ')">' +
|
191
|
+
'</td>';
|
192
|
+
};
|
193
|
+
|
194
|
+
rowChoiceTemplate = function (model) {
|
195
|
+
return '<td class="row-choice">' +
|
196
|
+
'<input type="radio"' +
|
197
|
+
'ng-model="table.chosenRow"' +
|
198
|
+
'ng-value="' + model + '"' +
|
199
|
+
'ng-click="itemChosen(' + model + ')">' +
|
200
|
+
'</td>';
|
201
|
+
};
|
202
|
+
|
203
|
+
activeRowTemplate = function (activeTest) {
|
204
|
+
return '<i class="icon-chevron-right selected-icon" ' +
|
205
|
+
'ng-show="' + activeTest + ' "></i>';
|
206
|
+
};
|
207
|
+
|
208
|
+
return {
|
209
|
+
require: '^alchTable',
|
210
|
+
restrict: 'A',
|
211
|
+
scope: true,
|
212
|
+
controller: 'AlchTableRowController',
|
213
|
+
compile: function (tElement, tAttrs) {
|
214
|
+
|
215
|
+
if (tAttrs.activeRow !== undefined) {
|
216
|
+
tElement.find('td:first-child').append(activeRowTemplate(tAttrs.activeRow));
|
217
|
+
}
|
218
|
+
|
219
|
+
if (tAttrs.rowSelect !== undefined) {
|
220
|
+
tElement.prepend(rowSelectTemplate(tAttrs.rowSelect));
|
221
|
+
}
|
222
|
+
|
223
|
+
if (tAttrs.rowChoice !== undefined) {
|
224
|
+
tElement.prepend(rowChoiceTemplate(tAttrs.rowChoice));
|
225
|
+
}
|
226
|
+
|
227
|
+
if (tAttrs.activeRow !== undefined) {
|
228
|
+
tElement.find('td').attr('ng-class', '{ "active-row": ' + tAttrs.activeRow + ' }');
|
229
|
+
}
|
230
|
+
|
231
|
+
return function (scope, element, attrs, alchTableController) {
|
232
|
+
alchTableController.addRow(scope.row);
|
233
|
+
|
234
|
+
if (attrs.rowSelect) {
|
235
|
+
scope.model = $parse(attrs.rowSelect)(scope);
|
236
|
+
|
237
|
+
if ($parse(attrs.rowSelectIf)(scope)) {
|
238
|
+
scope.model.unselectable = true;
|
239
|
+
}
|
240
|
+
|
241
|
+
scope.$watch('model.selected', function (selected) {
|
242
|
+
if (selected) {
|
243
|
+
element.addClass('selected-row');
|
244
|
+
} else {
|
245
|
+
element.removeClass('selected-row');
|
246
|
+
}
|
247
|
+
});
|
248
|
+
} else if (attrs.rowChoice) {
|
249
|
+
scope.model = $parse(attrs.rowChoice)(scope);
|
250
|
+
}
|
251
|
+
|
252
|
+
if (attrs.activeRow) {
|
253
|
+
scope.activeTest = $parse(attrs.activeRow)(scope);
|
254
|
+
}
|
255
|
+
|
256
|
+
scope.itemSelected = function (row) {
|
257
|
+
alchTableController.itemSelected(row);
|
258
|
+
};
|
259
|
+
|
260
|
+
scope.itemChosen = function (row) {
|
261
|
+
element.parent().find('.selected-row').removeClass('selected-row');
|
262
|
+
element.addClass('selected-row');
|
263
|
+
alchTableController.itemChosen(row);
|
264
|
+
};
|
265
|
+
};
|
266
|
+
}
|
267
|
+
};
|
268
|
+
}])
|
269
|
+
.controller('AlchTableRowController', ['$scope', function ($scope) {
|
270
|
+
$scope.row = {
|
271
|
+
cells: []
|
272
|
+
};
|
273
|
+
|
274
|
+
this.addCell = function (cell) {
|
275
|
+
$scope.row.cells.push(cell);
|
276
|
+
};
|
277
|
+
}])
|
278
|
+
.directive('alchTableCell', [function () {
|
279
|
+
return {
|
280
|
+
require: '^alchTableRow',
|
281
|
+
restrict: 'A',
|
282
|
+
scope: true,
|
283
|
+
controller: ['$scope', function ($scope) {
|
284
|
+
$scope.cell = { show: true };
|
285
|
+
}],
|
286
|
+
link: function (scope, element, attrs, alchTableRowController) {
|
287
|
+
alchTableRowController.addCell(scope.cell);
|
288
|
+
|
289
|
+
scope.$watch('cell.show', function (show) {
|
290
|
+
var display = show ? '' : 'none';
|
291
|
+
element.css('display', display);
|
292
|
+
});
|
293
|
+
}
|
294
|
+
};
|
295
|
+
}]);
|