Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update simple survey to work with the new dev kit #73

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"version": "1.1.0",
"dependencies": {
"angular-sortable-view": "^0.0.13",
"materia-widget-development-kit": "2.5.2"
"materia-widget-development-kit": "../Materia-Widget-Dev-Kit"
},
"devDependencies": {
"angular": "1.6.9",
Expand All @@ -20,9 +20,9 @@
"jest-coffee-preprocessor": "^1.0.0"
},
"scripts": {
"start": "webpack-dev-server",
"build-dev": "webpack",
"build": "webpack -p",
"start": "mwdk-start",
"build-dev": "mwdk-build-dev",
"build": "mwdk-build-prod",
"test": "TZ='America/New_York' jest --verbose",
"test-ci": "TZ='America/New_York' CI=true jest --ci --useStderr --coverage --coverageReporters text-summary cobertura",
"test-dev": "TZ='America/New_York' jest --coverage --coverageReporters text-summary lcov"
Expand Down
17 changes: 8 additions & 9 deletions src/creator.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Create an angular module to house our controller
SurveyWidget = angular.module 'SurveyWidgetCreator', ['ngMaterial', 'ngMessages', 'ngAnimate', 'ngSanitize', 'angular-sortable-view', 'ngAria']
angular.module 'SurveyWidgetCreator', ['ngMaterial', 'ngMessages', 'ngAnimate', 'ngSanitize', 'angular-sortable-view', 'ngAria']

SurveyWidget.config ['$mdThemingProvider', ($mdThemingProvider) ->
.config ['$mdThemingProvider', ($mdThemingProvider) ->
$mdThemingProvider.theme('default')
.primaryPalette('teal')
.accentPalette('blue-grey')
]
SurveyWidget.controller 'SurveyWidgetController', [ '$scope','$mdToast','$mdDialog','$sanitize','$compile', 'Resource', 'sanitizeHelper', '$timeout', ($scope, $mdToast, $mdDialog, $sanitize, $compile, Resource, sanitizeHelper, $timeout) ->
.controller 'SurveyWidgetController', [ '$scope','$mdToast','$mdDialog','$sanitize','$compile', 'Resource', 'sanitizeHelper', '$timeout', ($scope, $mdToast, $mdDialog, $sanitize, $compile, Resource, sanitizeHelper, $timeout) ->

$scope.acceptedMediaTypes = ['image']
mediaRef = null
Expand Down Expand Up @@ -387,8 +387,7 @@ SurveyWidget.controller 'SurveyWidgetController', [ '$scope','$mdToast','$mdDial

Materia.CreatorCore.start $scope
]

SurveyWidget.factory 'Resource', ['$sanitize', 'sanitizeHelper', ($sanitize, sanitizeHelper) ->
.factory 'Resource', ['$sanitize', 'sanitizeHelper', ($sanitize, sanitizeHelper) ->
buildQset: (title, questions, groups) ->
qsetItems = []
qset = {}
Expand Down Expand Up @@ -436,8 +435,7 @@ SurveyWidget.factory 'Resource', ['$sanitize', 'sanitizeHelper', ($sanitize, san

return processed
]

SurveyWidget.directive 'focusMe', ['$timeout', '$parse', ($timeout, $parse) ->
.directive 'focusMe', ['$timeout', '$parse', ($timeout, $parse) ->
link: (scope, element, attrs) ->
model = $parse(attrs.focusMe)
scope.$watch model, (value) ->
Expand All @@ -446,8 +444,7 @@ SurveyWidget.directive 'focusMe', ['$timeout', '$parse', ($timeout, $parse) ->
element[0].focus()
value
]

SurveyWidget.service 'sanitizeHelper', [() ->
.service 'sanitizeHelper', [() ->
SANITIZE_CHARACTERS =
'&' : '&',
'>' : '>',
Expand All @@ -471,3 +468,5 @@ SurveyWidget.service 'sanitizeHelper', [() ->
sanitize: sanitize
desanitize: desanitize
]

angular.bootstrap(document, ['SurveyWidgetCreator'])
9 changes: 6 additions & 3 deletions src/creator.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
<script src="//ajax.googleapis.com/ajax/libs/angular_material/1.1.8/angular-material.min.js"></script>
<script src="vendor/angular-sortable-view.min.js"></script>

<!-- MAIN CREATOR SCRIPT -->
<script src="creator.js"></script>

</head>

<body ng-app="SurveyWidgetCreator">
<body>
<md-content id="container" ng-controller="SurveyWidgetController">

<md-toolbar>
Expand Down Expand Up @@ -461,5 +460,9 @@ <h2>Edit Groups</h2>
</div>
</md-content>

<!-- MAIN CREATOR SCRIPT -->
<script src="creator.js"></script>


</body>
</html>
2 changes: 1 addition & 1 deletion src/ng-modal.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function() {
var app;

app = angular.module("PrivilegeWalkEngine");
app = angular.module("PrivilegeWalkEngine")

app.provider("ngModalDefaults", function() {
return {
Expand Down
8 changes: 5 additions & 3 deletions src/player.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
SurveyWidget = angular.module 'SurveyWidgetEngine', ['ngMaterial', 'angular-sortable-view', 'ngAria']
angular.module 'SurveyWidgetEngine', ['ngMaterial', 'angular-sortable-view', 'ngAria']

SurveyWidget.config ['$mdThemingProvider', ($mdThemingProvider) ->
.config ['$mdThemingProvider', ($mdThemingProvider) ->
$mdThemingProvider.theme('default')
.primaryPalette('teal')
.accentPalette('indigo')
]

SurveyWidget.controller 'SurveyWidgetEngineCtrl', ['$scope', '$mdToast','$mdDialog', '$timeout', '$mdLiveAnnouncer', ($scope, $mdToast, $mdDialog, $timeout, $mdLiveAnnouncer) ->
.controller 'SurveyWidgetEngineCtrl', ['$scope', '$mdToast','$mdDialog', '$timeout', '$mdLiveAnnouncer', ($scope, $mdToast, $mdDialog, $timeout, $mdLiveAnnouncer) ->

$scope.qset = null
$scope.instance = null
Expand Down Expand Up @@ -235,3 +235,5 @@ SurveyWidget.controller 'SurveyWidgetEngineCtrl', ['$scope', '$mdToast','$mdDial

Materia.Engine.start($scope)
]

angular.bootstrap(document, ['SurveyWidgetEngine'])
23 changes: 13 additions & 10 deletions src/player.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,9 @@
<!-- REQUIRED MATERIA JAVASCRIPT -->
<script src="materia.enginecore.js"></script>

<!-- ANGULAR DEPENDENCIES -->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angular_material/1.1.8/angular-material.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-animate.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-aria.min.js"></script>
<script src="vendor/angular-sortable-view.min.js"></script>

<!-- MAIN WIDGET SCRIPT -->
<script src="player.js"></script>
</head>

<body ng-app="SurveyWidgetEngine" ng-controller="SurveyWidgetEngineCtrl" ng-cloak>
<body ng-controller="SurveyWidgetEngineCtrl" ng-cloak>
<md-content id="container">
<md-toolbar>
<div class="md-toolbar-tools" layout="row">
Expand Down Expand Up @@ -221,5 +212,17 @@ <h2 aria-label="widget title {{instance.name}}">{{instance.name}}</h2>
</div>
</div>
</md-content>

<!-- ANGULAR DEPENDENCIES -->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angular_material/1.1.8/angular-material.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-animate.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-aria.min.js"></script>
<script src="vendor/angular-sortable-view.min.js"></script>

<!-- MAIN WIDGET SCRIPT -->
<script src="player.js"></script>

</body>

</html>
6 changes: 4 additions & 2 deletions src/scorescreen.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SurveyWidget = angular.module 'SurveyWidgetScorescreen', ['ngMaterial', 'ngMessages', 'ngAria']
angular.module 'SurveyWidgetScorescreen', ['ngMaterial', 'ngMessages', 'ngAria']

SurveyWidget.controller 'SurveyWidgetScoreCtrl', ['$scope', '$mdToast', '$mdDialog', ($scope, $mdToast, $mdDialog) ->
.controller 'SurveyWidgetScoreCtrl', ['$scope', '$mdToast', '$mdDialog', ($scope, $mdToast, $mdDialog) ->
$scope.qset = null
$scope.instance = null
$scope.groups = null
Expand Down Expand Up @@ -42,3 +42,5 @@ SurveyWidget.controller 'SurveyWidgetScoreCtrl', ['$scope', '$mdToast', '$mdDial
Materia.ScoreCore.hideResultsTable()
Materia.ScoreCore.start($scope)
]

angular.bootstrap(document, ['SurveyWidgetScorescreen'])
23 changes: 12 additions & 11 deletions src/scorescreen.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,9 @@
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="materia.scorecore.js"></script>

<!-- ANGULAR DEPENDENCIES -->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-animate.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-aria.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-messages.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angular_material/1.1.8/angular-material.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/labjs/2.0.3/LAB.min.js"></script>

<!-- MAIN WIDGET SCRIPT -->
<script src="scorescreen.js"></script>
</head>

<body ng-app="SurveyWidgetScorescreen" ng-controller="SurveyWidgetScoreCtrl" ng-cloak>
<body ng-controller="SurveyWidgetScoreCtrl" ng-cloak>
<md-content id="container">

<div layout-gt-sm="row" layout="column" id="content">
Expand Down Expand Up @@ -59,5 +49,16 @@
</div>
</div>
</md-content>

<!-- ANGULAR DEPENDENCIES -->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-animate.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-aria.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-messages.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angular_material/1.1.8/angular-material.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/labjs/2.0.3/LAB.min.js"></script>

<!-- MAIN WIDGET SCRIPT -->
<script src="scorescreen.js"></script>
</body>
</html>
60 changes: 16 additions & 44 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const outputPath = path.join(__dirname, 'build')
const widgetWebpack = require('materia-widget-development-kit/webpack-widget')

const rules = widgetWebpack.getDefaultRules()
const entries = widgetWebpack.getDefaultEntries()
const copy = widgetWebpack.getDefaultCopyList()

const customCopy = copy.concat([
Expand All @@ -24,57 +23,30 @@ const customCopy = copy.concat([
}
])

entries['scorescreen.js'] = [
srcPath+'scorescreen.coffee'
]

entries['scorescreen.css'] = [
srcPath+'scorescreen.html',
srcPath+'scorescreen.scss'
]

entries['guides/creator.temp.html'] = [
srcPath+'_guides/creator.md'
]

entries['guides/player.temp.html'] = [
srcPath+'_guides/player.md'
]

// this is needed to prevent html-loader from causing issues with
// style tags in the player using angular
let customHTMLAndReplaceRule = {
test: /\.html$/i,
exclude: /node_modules/,
use: [
{
loader: 'file-loader',
options: { name: '[name].html' }
},
{
loader: 'extract-loader'
},
{
loader: 'string-replace-loader',
options: { multiple: widgetWebpack.materiaJSReplacements }
},
{
loader: 'html-loader',
options: {
minifyCSS: false
}
}
const entries = {
'player': [
path.join(srcPath, 'player.html'),
path.join(srcPath, 'player.coffee'),
path.join(srcPath, 'player.scss')
],
'creator': [
path.join(srcPath, 'creator.html'),
path.join(srcPath, 'creator.coffee'),
path.join(srcPath, 'creator.scss')
],
'scorescreen': [
path.join(srcPath, 'scorescreen.html'),
path.join(srcPath, 'scorescreen.coffee'),
path.join(srcPath, 'scorescreen.scss')
]
}

let customRules = [
rules.loaderDoNothingToJs,
rules.loaderCompileCoffee,
rules.copyImages,
customHTMLAndReplaceRule, // <--- replaces "rules.loadHTMLAndReplaceMateriaScripts"
rules.loadAndPrefixCSS,
rules.loadHTMLAndReplaceMateriaScripts,
rules.loadAndPrefixSASS,
rules.loadAndCompileMarkdown
]


Expand Down
Loading