1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00

convert coffeescript comments to valid jsdoc

This commit is contained in:
Sylvain 2018-11-21 09:42:26 +01:00
parent 8a03b0b4f2
commit d250dfa1d3
17 changed files with 451 additions and 451 deletions

View File

@ -15,21 +15,21 @@
// Here are the various options for this parameter
const userValidities = ['once', 'forever']
// #
// Controller used in the coupon creation page
// #
/**
* Controller used in the coupon creation page
*/
Application.Controllers.controller('NewCouponController', ['$scope', '$state', 'Coupon', 'growl', '_t',
function ($scope, $state, Coupon, growl, _t) {
// # Values for the coupon currently created
// Values for the coupon currently created
$scope.coupon = {
active: true,
type: 'percent_off'
}
// # Options for the validity per user
// Options for the validity per user
$scope.validities = userValidities
// # Default parameters for AngularUI-Bootstrap datepicker (used for coupon validity limit selection)
// Default parameters for AngularUI-Bootstrap datepicker (used for coupon validity limit selection)
$scope.datePicker = {
format: Fablab.uibDateFormat,
opened: false, // default: datePicker is not shown
@ -39,19 +39,19 @@ Application.Controllers.controller('NewCouponController', ['$scope', '$state', '
}
}
// #
// Shows/hides the validity limit datepicker
// @param $event {Object} jQuery event object
// #
/**
* Shows/hides the validity limit datepicker
* @param $event {Object} jQuery event object
*/
$scope.toggleDatePicker = function ($event) {
$event.preventDefault()
$event.stopPropagation()
return $scope.datePicker.opened = !$scope.datePicker.opened
}
// #
// Callback to save the new coupon in $scope.coupon and redirect the user to the listing page
// #
/**
* Callback to save the new coupon in $scope.coupon and redirect the user to the listing page
*/
return $scope.saveCoupon = () =>
Coupon.save({ coupon: $scope.coupon }, coupon => $state.go('app.admin.pricing')
, function (err) {
@ -61,26 +61,26 @@ Application.Controllers.controller('NewCouponController', ['$scope', '$state', '
}
])
// #
// Controller used in the coupon edition page
// #
/**
* Controller used in the coupon edition page
*/
Application.Controllers.controller('EditCouponController', ['$scope', '$state', 'Coupon', 'couponPromise', '_t', 'growl',
function ($scope, $state, Coupon, couponPromise, _t, growl) {
/* PUBLIC SCOPE */
// # Used in the form to freeze unmodifiable fields
// Used in the form to freeze unmodifiable fields
$scope.mode = 'EDIT'
// # Coupon to edit
// Coupon to edit
$scope.coupon = couponPromise
// # Options for the validity per user
// Options for the validity per user
$scope.validities = userValidities
// # Mapping for validation errors
// Mapping for validation errors
$scope.errors = {}
// # Default parameters for AngularUI-Bootstrap datepicker (used for coupon validity limit selection)
// Default parameters for AngularUI-Bootstrap datepicker (used for coupon validity limit selection)
$scope.datePicker = {
format: Fablab.uibDateFormat,
opened: false, // default: datePicker is not shown
@ -90,19 +90,19 @@ Application.Controllers.controller('EditCouponController', ['$scope', '$state',
}
}
// #
// Shows/hides the validity limit datepicker
// @param $event {Object} jQuery event object
// #
/**
* Shows/hides the validity limit datepicker
* @param $event {Object} jQuery event object
*/
$scope.toggleDatePicker = function ($event) {
$event.preventDefault()
$event.stopPropagation()
return $scope.datePicker.opened = !$scope.datePicker.opened
}
// #
// Callback to save the coupon's changes to the API
// #
/**
* Callback to save the coupon's changes to the API
*/
$scope.updateCoupon = function () {
$scope.errors = {}
return Coupon.update({ id: $scope.coupon.id }, { coupon: $scope.coupon }, coupon => $state.go('app.admin.pricing')
@ -114,9 +114,9 @@ Application.Controllers.controller('EditCouponController', ['$scope', '$state',
/* PRIVATE SCOPE */
// #
// Kind of constructor: these actions will be realized first when the controller is loaded
// #
/**
* Kind of constructor: these actions will be realized first when the controller is loaded
*/
const initialize = function () {
// parse the date if any
if (couponPromise.valid_until) {
@ -124,7 +124,7 @@ Application.Controllers.controller('EditCouponController', ['$scope', '$state',
}
}
// # !!! MUST BE CALLED AT THE END of the controller
// !!! MUST BE CALLED AT THE END of the controller
return initialize()
}
])

View File

@ -21,47 +21,47 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
function ($scope, $state, $rootScope, es, Statistics, _t) {
/* PRIVATE STATIC CONSTANTS */
// # height of the HTML/SVG charts elements in pixels
// height of the HTML/SVG charts elements in pixels
const CHART_HEIGHT = 500
// # Label of the charts' horizontal axes
// Label of the charts' horizontal axes
const X_AXIS_LABEL = _t('date')
// # Label of the charts' vertical axes
// Label of the charts' vertical axes
const Y_AXIS_LABEL = _t('number')
// # Colors for the line charts. Each new line uses the next color in this array
// Colors for the line charts. Each new line uses the next color in this array
const CHART_COLORS = ['#b35a94', '#1c5794', '#00b49e', '#6fac48', '#ebcf4a', '#fd7e33', '#ca3436', '#a26e3a']
/* PUBLIC SCOPE */
// # ui-view transitions optimization: if true, the charts will never be refreshed
// ui-view transitions optimization: if true, the charts will never be refreshed
$scope.preventRefresh = false
// # statistics structure in elasticSearch
// statistics structure in elasticSearch
$scope.statistics = []
// # statistics data recovered from elasticSearch
// statistics data recovered from elasticSearch
$scope.data = null
// # default interval: one day
// default interval: one day
$scope.display =
{ interval: 'week' }
// # active tab will be set here
// active tab will be set here
$scope.selectedIndex = null
// # for palmares graphs, filters values are stored here
// for palmares graphs, filters values are stored here
$scope.ranking = {
sortCriterion: 'ca',
groupCriterion: 'subType'
}
// # default: we do not open the datepicker menu
// default: we do not open the datepicker menu
$scope.datePicker =
{ show: false }
// # datePicker parameters for interval beginning
// datePicker parameters for interval beginning
$scope.datePickerStart = {
format: Fablab.uibDateFormat,
opened: false, // default: datePicker is not shown
@ -73,7 +73,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
}
}
// # datePicker parameters for interval ending
// datePicker parameters for interval ending
$scope.datePickerEnd = {
format: Fablab.uibDateFormat,
opened: false, // default: datePicker is not shown
@ -85,23 +85,23 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
}
}
// #
// Callback to open the datepicker (interval start)
// @param {Object} jQuery event object
// #
/**
* Callback to open the datepicker (interval start)
* @param {Object} jQuery event object
*/
$scope.toggleStartDatePicker = $event => toggleDatePicker($event, $scope.datePickerStart)
// #
// Callback to open the datepicker (interval end)
// @param {Object} jQuery event object
// #
/**
* Callback to open the datepicker (interval end)
* @param {Object} jQuery event object
*/
$scope.toggleEndDatePicker = $event => toggleDatePicker($event, $scope.datePickerEnd)
// #
// Callback called when the active tab is changed.
// Recover the current tab and store its value in $scope.selectedIndex
// @param tab {Object} elasticsearch statistic structure
// #
/**
* Callback called when the active tab is changed.
* Recover the current tab and store its value in $scope.selectedIndex
* @param tab {Object} elasticsearch statistic structure
*/
$scope.setActiveTab = function (tab) {
$scope.selectedIndex = tab
$scope.ranking.groupCriterion = 'subType'
@ -113,9 +113,9 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
return refreshChart()
}
// #
// Callback to close the date-picking popup and refresh the results
// #
/**
* Callback to close the date-picking popup and refresh the results
*/
$scope.validateDateChange = function () {
$scope.datePicker.show = false
return refreshChart()
@ -123,9 +123,9 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
/* PRIVATE SCOPE */
// #
// Kind of constructor: these actions will be realized first when the controller is loaded
// #
/**
* Kind of constructor: these actions will be realized first when the controller is loaded
*/
const initialize = function () {
Statistics.query(function (stats) {
$scope.statistics = stats
@ -148,20 +148,20 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
})
}
// #
// Generic function to toggle a bootstrap datePicker
// @param $event {Object} jQuery event object
// @param datePicker {Object} settings object of the concerned datepicker. Must have an 'opened' property
// #
/**
* Generic function to toggle a bootstrap datePicker
* @param $event {Object} jQuery event object
* @param datePicker {Object} settings object of the concerned datepicker. Must have an 'opened' property
*/
var toggleDatePicker = function ($event, datePicker) {
$event.preventDefault()
$event.stopPropagation()
return datePicker.opened = !datePicker.opened
}
// #
// Query elasticSearch according to the current parameters and update the chart
// #
/**
* Query elasticSearch according to the current parameters and update the chart
*/
var refreshChart = function () {
if ($scope.selectedIndex && !$scope.preventRefresh) {
return query($scope.selectedIndex, function (aggregations, error) {
@ -180,9 +180,9 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
}
}
// #
// Callback used in NVD3 to print timestamps as literal dates on the X axis
// #
/**
* Callback used in NVD3 to print timestamps as literal dates on the X axis
*/
const xAxisTickFormatFunction = function (d, x, y) {
/* WARNING !! These tests (typeof/instanceof) may become broken on nvd3 update */
if ($scope.display.interval === 'day') {
@ -209,10 +209,10 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
}
}
// #
// Format aggregations as retuned by elasticSearch to an understandable format for NVD3
// @param aggs {Object} as returned by elasticsearch
// #
/**
* Format aggregations as retuned by elasticSearch to an understandable format for NVD3
* @param aggs {Object} as returned by elasticsearch
*/
var formatAggregations = function (aggs) {
const format = {}
@ -260,12 +260,12 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
return format
}
// #
// Format aggregations for ranking charts to an understandable format for NVD3
// @param aggs {Object} as returned by elasticsearch
// @param limit {number} limit the number of stats in the bar chart
// @param typeKey {String} field name witch results are grouped by
// #
/**
* Format aggregations for ranking charts to an understandable format for NVD3
* @param aggs {Object} as returned by elasticsearch
* @param limit {number} limit the number of stats in the bar chart
* @param typeKey {String} field name witch results are grouped by
*/
var formatRankingAggregations = function (aggs, limit, typeKey) {
const format =
{ ranking: [] }
@ -294,11 +294,11 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
return format
}
// #
// For BarCharts, return the label for a given bar
// @param key {string} raw value of the label
// @param typeKey {string} name of the field the results are grouped by
// #
/**
* For BarCharts, return the label for a given bar
* @param key {string} raw value of the label
* @param typeKey {string} name of the field the results are grouped by
*/
var getRankingLabel = function (key, typeKey) {
if ($scope.selectedIndex) {
if (typeKey === 'subType') {
@ -323,13 +323,13 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
}
}
// #
// Prepare the elasticSearch query for the stats matching the current controller's parameters
// @param index {{id:{number}, es_type_key:{string}, label:{string}, table:{boolean}, additional_fields:{Array},
// types:{Array}, graph:{Object}}} elasticSearch type in stats index to query
// @param callback {function} function be to run after results were retrieved,
// it will receive two parameters : results {Array}, error {String} (if any)
// #
/**
* Prepare the elasticSearch query for the stats matching the current controller's parameters
* @param index {{id:{number}, es_type_key:{string}, label:{string}, table:{boolean}, additional_fields:{Array},
* types:{Array}, graph:{Object}}} elasticSearch type in stats index to query
* @param callback {function} function be to run after results were retrieved,
* it will receive two parameters : results {Array}, error {String} (if any)
*/
var query = function (index, callback) {
// invalid callback handeling
if (typeof (callback) !== 'function') {
@ -385,13 +385,13 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
}
}
// #
// Run the elasticSearch query to retreive the /stats/type aggregations
// @param esType {String} elasticSearch document type (subscription|machine|training|...)
// @param statType {String} statistics type (year|month|hour|booking|...)
// @param callback {function} function be to run after results were retrieved,
// it will receive two parameters : results {Array}, error {String} (if any)
// #
/**
* Run the elasticSearch query to retreive the /stats/type aggregations
* @param esType {String} elasticSearch document type (subscription|machine|training|...)
* @param statType {String} statistics type (year|month|hour|booking|...)
* @param callback {function} function be to run after results were retrieved,
* it will receive two parameters : results {Array}, error {String} (if any)
*/
var queryElasticStats = function (esType, statType, callback) {
// handle invalid callback
if (typeof (callback) !== 'function') {
@ -423,14 +423,14 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
})
}
// #
// For ranking displays, run the elasticSearch query to retreive the /stats/type aggregations
// @param esType {string} elasticSearch document type (subscription|machine|training|...)
// @param groupKey {string} statistics subtype or custom field
// @param sortKey {string} statistics type or 'ca'
// @param callback {function} function be to run after results were retrieved,
// it will receive two parameters : results {Array}, error {String} (if any)
// #
/**
* For ranking displays, run the elasticSearch query to retreive the /stats/type aggregations
* @param esType {string} elasticSearch document type (subscription|machine|training|...)
* @param groupKey {string} statistics subtype or custom field
* @param sortKey {string} statistics type or 'ca'
* @param callback {function} function be to run after results were retrieved,
* it will receive two parameters : results {Array}, error {String} (if any)
*/
var queryElasticRanking = function (esType, groupKey, sortKey, callback) {
// handle invalid callback
if (typeof (callback) !== 'function') {
@ -457,20 +457,20 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
})
}
// #
// Parse a final elastic results bucket and return a D3 compatible object
// @param bucket {{key_as_string:{String}, key:{Number}, doc_count:{Number}, total:{{value:{Number}}}}} interval bucket
// #
/**
* Parse a final elastic results bucket and return a D3 compatible object
* @param bucket {{key_as_string:{String}, key:{Number}, doc_count:{Number}, total:{{value:{Number}}}}} interval bucket
*/
const parseElasticBucket = bucket => [ bucket.key, bucket.total.value ]
// #
// Build an object representing the content of the REST-JSON query to elasticSearch, based on the parameters
// currently defined for data aggegations.
// @param type {String} statistics type (visit|rdv|rating|ca|plan|account|search|...)
// @param interval {String} statistics interval (year|quarter|month|week|day|hour|minute|second)
// @param intervalBegin {moment} statitics interval beginning (moment.js type)
// @param intervalEnd {moment} statitics interval ending (moment.js type)
// #
/**
* Build an object representing the content of the REST-JSON query to elasticSearch, based on the parameters
* currently defined for data aggegations.
* @param type {String} statistics type (visit|rdv|rating|ca|plan|account|search|...)
* @param interval {String} statistics interval (year|quarter|month|week|day|hour|minute|second)
* @param intervalBegin {moment} statitics interval beginning (moment.js type)
* @param intervalEnd {moment} statitics interval ending (moment.js type)
*/
var buildElasticAggregationsQuery = function (type, interval, intervalBegin, intervalEnd) {
const q = {
'query': {
@ -532,14 +532,14 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
return q
}
// #
// Build an object representing the content of the REST-JSON query to elasticSearch, based on the parameters
// currently defined for data aggegations.
// @param groupKey {String} statistics subtype or custom field
// @param sortKey {String} statistics type or 'ca'
// @param intervalBegin {moment} statitics interval beginning (moment.js type)
// @param intervalEnd {moment} statitics interval ending (moment.js type)
// #
/**
* Build an object representing the content of the REST-JSON query to elasticSearch, based on the parameters
* currently defined for data aggegations.
* @param groupKey {String} statistics subtype or custom field
* @param sortKey {String} statistics type or 'ca'
* @param intervalBegin {moment} statitics interval beginning (moment.js type)
* @param intervalEnd {moment} statitics interval ending (moment.js type)
*/
var buildElasticAggregationsRankingQuery = function (groupKey, sortKey, intervalBegin, intervalEnd) {
const q = {
'query': {
@ -603,12 +603,12 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
return q
}
// #
// Redraw the NDV3 chart using the provided data
// @param chart_type {String} stackedAreaChart|discreteBarChart|lineChart
// @param data {Array} array of NVD3 dataSources
// @param type {String} which chart to update (statistic type key)
// #
/**
* Redraw the NDV3 chart using the provided data
* @param chart_type {String} stackedAreaChart|discreteBarChart|lineChart
* @param data {Array} array of NVD3 dataSources
* @param type {String} which chart to update (statistic type key)
*/
var updateChart = function (chart_type, data, type) {
const id = `#chart-${type} svg`
@ -666,9 +666,9 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
})
}
// #
// Given an NVD3 line chart axis, scale it to display ordinated dates, according to the given arguments
// #
/**
* Given an NVD3 line chart axis, scale it to display ordinated dates, according to the given arguments
*/
var setTimeScale = function (nvd3Axis, nvd3Scale, argsArray) {
const scale = d3.time.scale()
@ -681,9 +681,9 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
}
}
// #
// Translate line chart data in dates row to bar chart data, one bar per type.
// #
/**
* Translate line chart data in dates row to bar chart data, one bar per type.
*/
var prepareDataForBarChart = function (data, type) {
const newData = [{
key: type,
@ -703,15 +703,15 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
return newData
}
// #
// Sort the provided array, in the specified order, on the value returned by the callback.
// This is a stable-sorting algorithm implementation, ie. two call with the same array will return the same results
// orders, especially with equal values.
// @param array {Array} the array to sort
// @param order {string} 'ASC' or 'DESC'
// @param getValue {function} the callback which will return the value on which the sort will occurs
// @returns {Array}
// #
/**
* Sort the provided array, in the specified order, on the value returned by the callback.
* This is a stable-sorting algorithm implementation, ie. two call with the same array will return the same results
* orders, especially with equal values.
* @param array {Array} the array to sort
* @param order {string} 'ASC' or 'DESC'
* @param getValue {function} the callback which will return the value on which the sort will occurs
* @returns {Array}
*/
var stableSort = function (array, order, getValue) {
// prepare sorting
const keys_order = []
@ -744,7 +744,7 @@ Application.Controllers.controller('GraphsController', ['$scope', '$state', '$ro
return result
}
// # !!! MUST BE CALLED AT THE END of the controller
// !!! MUST BE CALLED AT THE END of the controller
return initialize()
}
])

View File

@ -12,24 +12,24 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
Application.Controllers.controller('GroupsController', ['$scope', 'groupsPromise', 'Group', 'growl', '_t', function ($scope, groupsPromise, Group, growl, _t) {
// # List of users groups
// List of users groups
$scope.groups = groupsPromise
// # Default: we show only enabled groups
// Default: we show only enabled groups
$scope.groupFiltering = 'enabled'
// # Available options for filtering groups by status
// Available options for filtering groups by status
$scope.filterDisabled = [
'enabled',
'disabled',
'all'
]
// #
// Removes the newly inserted but not saved group / Cancel the current group modification
// @param rowform {Object} see http://vitalets.github.io/angular-xeditable/
// @param index {number} group index in the $scope.groups array
// #
/**
* Removes the newly inserted but not saved group / Cancel the current group modification
* @param rowform {Object} see http://vitalets.github.io/angular-xeditable/
* @param index {number} group index in the $scope.groups array
*/
$scope.cancelGroup = function (rowform, index) {
if ($scope.groups[index].id != null) {
return rowform.$cancel()
@ -38,20 +38,20 @@ Application.Controllers.controller('GroupsController', ['$scope', 'groupsPromise
}
}
// #
// Creates a new empty entry in the $scope.groups array
// #
/**
* Creates a new empty entry in the $scope.groups array
*/
$scope.addGroup = function () {
$scope.inserted =
{ name: '' }
return $scope.groups.push($scope.inserted)
}
// #
// Saves a new group / Update an existing group to the server (form validation callback)
// @param data {Object} group name
// @param [id] {number} group id, in case of update
// #
/**
* Saves a new group / Update an existing group to the server (form validation callback)
* @param data {Object} group name
* @param [id] {number} group id, in case of update
*/
$scope.saveGroup = function (data, id) {
if (id != null) {
return Group.update({ id }, { group: data }, response => growl.success(_t('group_form.changes_successfully_saved'))
@ -68,10 +68,10 @@ Application.Controllers.controller('GroupsController', ['$scope', 'groupsPromise
}
}
// #
// Deletes the group at the specified index
// @param index {number} group index in the $scope.groups array
// #
/**
* Deletes the group at the specified index
* @param index {number} group index in the $scope.groups array
*/
$scope.removeGroup = index =>
Group.delete({ id: $scope.groups[index].id }, function (resp) {
growl.success(_t('group_form.group_successfully_deleted'))
@ -79,10 +79,10 @@ Application.Controllers.controller('GroupsController', ['$scope', 'groupsPromise
}
, error => growl.error(_t('group_form.unable_to_delete_group_because_some_users_and_or_groups_are_still_linked_to_it')))
// #
// Enable/disable the group at the specified index
// @param index {number} group index in the $scope.groups array
// #
/**
* Enable/disable the group at the specified index
* @param index {number} group index in the $scope.groups array
*/
return $scope.toggleDisableGroup = function (index) {
const group = $scope.groups[index]
if (!group.disabled && (group.users > 0)) {

View File

@ -14,7 +14,7 @@ Application.Controllers.controller('OpenAPIClientsController', ['$scope', 'clien
function ($scope, clientsPromise, growl, OpenAPIClient, dialogs, _t) {
/* PUBLIC SCOPE */
// # clients list
// clients list
$scope.clients = clientsPromise
$scope.order = null
$scope.clientFormVisible = false
@ -24,7 +24,7 @@ Application.Controllers.controller('OpenAPIClientsController', ['$scope', 'clien
// Change the order criterion to the one provided
// @param orderBy {string} ordering criterion
// #
//
$scope.setOrder = function (orderBy) {
if ($scope.order === orderBy) {
return $scope.order = `-${orderBy}`

View File

@ -11,22 +11,22 @@
*/
'use strict'
// #
// Controller used in price category creation/edition form dialog
// #
/**
* Controller used in price category creation/edition form dialog
*/
Application.Controllers.controller('PriceCategoryController', ['$scope', '$uibModalInstance', 'category',
function ($scope, $uibModalInstance, category) {
// # Price category to edit/empty object for new category
// Price category to edit/empty object for new category
$scope.category = category
// #
// Callback for form validation
// #
/**
* Callback for form validation
*/
$scope.ok = () => $uibModalInstance.close($scope.category)
// #
// Do not validate the modifications, hide the modal
// #
/**
* Do not validate the modifications, hide the modal
*/
return $scope.cancel = () => $uibModalInstance.dismiss('cancel')
}
])

View File

@ -14,20 +14,20 @@
Application.Controllers.controller('ProjectElementsController', ['$scope', '$state', 'Component', 'Licence', 'Theme', 'componentsPromise', 'licencesPromise', 'themesPromise',
function ($scope, $state, Component, Licence, Theme, componentsPromise, licencesPromise, themesPromise) {
// # Materials list (plastic, wood ...)
// Materials list (plastic, wood ...)
$scope.components = componentsPromise
// # Licences list (Creative Common ...)
// Licences list (Creative Common ...)
$scope.licences = licencesPromise
// # Themes list (cooking, sport ...)
// Themes list (cooking, sport ...)
$scope.themes = themesPromise
// #
// Saves a new component / Update an existing material to the server (form validation callback)
// @param data {Object} component name
// @param [data] {number} component id, in case of update
// #
/**
* Saves a new component / Update an existing material to the server (form validation callback)
* @param data {Object} component name
* @param [data] {number} component id, in case of update
*/
$scope.saveComponent = function (data, id) {
if (id != null) {
return Component.update({ id }, data)
@ -36,29 +36,29 @@ Application.Controllers.controller('ProjectElementsController', ['$scope', '$sta
}
}
// #
// Deletes the component at the specified index
// @param index {number} component index in the $scope.components array
// #
/**
* Deletes the component at the specified index
* @param index {number} component index in the $scope.components array
*/
$scope.removeComponent = function (index) {
Component.delete($scope.components[index])
return $scope.components.splice(index, 1)
}
// #
// Creates a new empty entry in the $scope.components array
// #
/**
* Creates a new empty entry in the $scope.components array
*/
$scope.addComponent = function () {
$scope.inserted =
{ name: '' }
return $scope.components.push($scope.inserted)
}
// #
// Removes the newly inserted but not saved component / Cancel the current component modification
// @param rowform {Object} see http://vitalets.github.io/angular-xeditable/
// @param index {number} component index in the $scope.components array
// #
/**
* Removes the newly inserted but not saved component / Cancel the current component modification
* @param rowform {Object} see http://vitalets.github.io/angular-xeditable/
* @param index {number} component index in the $scope.components array
*/
$scope.cancelComponent = function (rowform, index) {
if ($scope.components[index].id != null) {
return rowform.$cancel()
@ -67,11 +67,11 @@ Application.Controllers.controller('ProjectElementsController', ['$scope', '$sta
}
}
// #
// Saves a new theme / Update an existing theme to the server (form validation callback)
// @param data {Object} theme name
// @param [data] {number} theme id, in case of update
// #
/**
* Saves a new theme / Update an existing theme to the server (form validation callback)
* @param data {Object} theme name
* @param [data] {number} theme id, in case of update
*/
$scope.saveTheme = function (data, id) {
if (id != null) {
return Theme.update({ id }, data)
@ -80,29 +80,29 @@ Application.Controllers.controller('ProjectElementsController', ['$scope', '$sta
}
}
// #
// Deletes the theme at the specified index
// @param index {number} theme index in the $scope.themes array
// #
/**
* Deletes the theme at the specified index
* @param index {number} theme index in the $scope.themes array
*/
$scope.removeTheme = function (index) {
Theme.delete($scope.themes[index])
return $scope.themes.splice(index, 1)
}
// #
// Creates a new empty entry in the $scope.themes array
// #
/**
* Creates a new empty entry in the $scope.themes array
*/
$scope.addTheme = function () {
$scope.inserted =
{ name: '' }
return $scope.themes.push($scope.inserted)
}
// #
// Removes the newly inserted but not saved theme / Cancel the current theme modification
// @param rowform {Object} see http://vitalets.github.io/angular-xeditable/
// @param index {number} theme index in the $scope.themes array
// #
/**
* Removes the newly inserted but not saved theme / Cancel the current theme modification
* @param rowform {Object} see http://vitalets.github.io/angular-xeditable/
* @param index {number} theme index in the $scope.themes array
*/
$scope.cancelTheme = function (rowform, index) {
if ($scope.themes[index].id != null) {
return rowform.$cancel()
@ -111,11 +111,11 @@ Application.Controllers.controller('ProjectElementsController', ['$scope', '$sta
}
}
// #
// Saves a new licence / Update an existing licence to the server (form validation callback)
// @param data {Object} licence name and description
// @param [data] {number} licence id, in case of update
// #
/**
* Saves a new licence / Update an existing licence to the server (form validation callback)
* @param data {Object} licence name and description
* @param [data] {number} licence id, in case of update
*/
$scope.saveLicence = function (data, id) {
if (id != null) {
return Licence.update({ id }, data)
@ -124,18 +124,18 @@ Application.Controllers.controller('ProjectElementsController', ['$scope', '$sta
}
}
// #
// Deletes the licence at the specified index
// @param index {number} licence index in the $scope.licences array
// #
/**
* Deletes the licence at the specified index
* @param index {number} licence index in the $scope.licences array
*/
$scope.removeLicence = function (index) {
Licence.delete($scope.licences[index])
return $scope.licences.splice(index, 1)
}
// #
// Creates a new empty entry in the $scope.licences array
// #
/**
* Creates a new empty entry in the $scope.licences array
*/
$scope.addLicence = function () {
$scope.inserted = {
name: '',
@ -144,11 +144,11 @@ Application.Controllers.controller('ProjectElementsController', ['$scope', '$sta
return $scope.licences.push($scope.inserted)
}
// #
// Removes the newly inserted but not saved licence / Cancel the current licence modification
// @param rowform {Object} see http://vitalets.github.io/angular-xeditable/
// @param index {number} licence index in the $scope.licences array
// #
/**
* Removes the newly inserted but not saved licence / Cancel the current licence modification
* @param rowform {Object} see http://vitalets.github.io/angular-xeditable/
* @param index {number} licence index in the $scope.licences array
*/
return $scope.cancelLicence = function (rowform, index) {
if ($scope.licences[index].id != null) {
return rowform.$cancel()

View File

@ -16,13 +16,13 @@ Application.Controllers.controller('SettingsController', ['$scope', 'Setting', '
function ($scope, Setting, growl, settingsPromise, cgvFile, cguFile, logoFile, logoBlackFile, faviconFile, profileImageFile, CSRF, _t) {
/* PUBLIC SCOPE */
// # timepickers steps configuration
// timepickers steps configuration
$scope.timepicker = {
hstep: 1,
mstep: 15
}
// # API URL where the upload forms will be posted
// API URL where the upload forms will be posted
$scope.actionUrl = {
cgu: '/api/custom_assets',
cgv: '/api/custom_assets',
@ -32,7 +32,7 @@ Application.Controllers.controller('SettingsController', ['$scope', 'Setting', '
profileImage: '/api/custom_assets'
}
// # Form actions on the above URL
// Form actions on the above URL
$scope.methods = {
cgu: 'post',
cgv: 'post',
@ -42,13 +42,13 @@ Application.Controllers.controller('SettingsController', ['$scope', 'Setting', '
profileImage: 'post'
}
// # Are we uploading the files currently (if so, display the loader)
// Are we uploading the files currently (if so, display the loader)
$scope.loader = {
cgu: false,
cgv: false
}
// # various parametrable settings
// various parametrable settings
$scope.twitterSetting = { name: 'twitter_name', value: settingsPromise.twitter_name }
$scope.aboutTitleSetting = { name: 'about_title', value: settingsPromise.about_title }
$scope.aboutBodySetting = { name: 'about_body', value: settingsPromise.about_body }
@ -119,11 +119,11 @@ Application.Controllers.controller('SettingsController', ['$scope', 'Setting', '
value: (settingsPromise.display_name_enable === 'true')
}
// #
// For use with 'ng-class', returns the CSS class name for the uploads previews.
// The preview may show a placeholder or the content of the file depending on the upload state.
// @param v {*} any attribute, will be tested for truthiness (see JS evaluation rules)
// #
/**
* For use with 'ng-class', returns the CSS class name for the uploads previews.
* The preview may show a placeholder or the content of the file depending on the upload state.
* @param v {*} any attribute, will be tested for truthiness (see JS evaluation rules)
*/
$scope.fileinputClass = function (v) {
if (v) {
return 'fileinput-exists'
@ -132,10 +132,10 @@ Application.Controllers.controller('SettingsController', ['$scope', 'Setting', '
}
}
// #
// Callback to save the setting value to the database
// @param setting {{value:*, name:string}} note that the value will be stringified
// #
/**
* Callback to save the setting value to the database
* @param setting {{value:*, name:string}} note that the value will be stringified
*/
$scope.save = function (setting) {
// trim empty html
let value
@ -157,12 +157,12 @@ Application.Controllers.controller('SettingsController', ['$scope', 'Setting', '
, error => console.log(error))
}
// #
// For use with ngUpload (https://github.com/twilson63/ngUpload).
// Intended to be the callback when the upload is done: Any raised error will be displayed in a growl
// message. If everything goes fine, a growl success message is shown.
// @param content {Object} JSON - The upload's result
// #
/**
* For use with ngUpload (https://github.com/twilson63/ngUpload).
* Intended to be the callback when the upload is done: Any raised error will be displayed in a growl
* message. If everything goes fine, a growl success message is shown.
* @param content {Object} JSON - The upload's result
*/
$scope.submited = function (content) {
if ((content.custom_asset == null)) {
$scope.alerts = []
@ -201,16 +201,16 @@ Application.Controllers.controller('SettingsController', ['$scope', 'Setting', '
}
}
// #
// @param target {String} 'cgu' | 'cgv'
// #
/**
* @param target {String} 'cgu' | 'cgv'
*/
$scope.addLoader = target => $scope.loader[target] = true
/* PRIVATE SCOPE */
// #
// Kind of constructor: these actions will be realized first when the controller is loaded
// #
/**
* Kind of constructor: these actions will be realized first when the controller is loaded
*/
const initialize = function () {
// set the authenticity tokens in the forms
CSRF.setMetaTags()

View File

@ -12,14 +12,14 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
Application.Controllers.controller('TagsController', ['$scope', 'tagsPromise', 'Tag', 'growl', '_t', function ($scope, tagsPromise, Tag, growl, _t) {
// # List of users's tags
// List of users's tags
$scope.tags = tagsPromise
// #
// Removes the newly inserted but not saved tag / Cancel the current tag modification
// @param rowform {Object} see http://vitalets.github.io/angular-xeditable/
// @param index {number} tag index in the $scope.tags array
// #
/**
* Removes the newly inserted but not saved tag / Cancel the current tag modification
* @param rowform {Object} see http://vitalets.github.io/angular-xeditable/
* @param index {number} tag index in the $scope.tags array
*/
$scope.cancelTag = function (rowform, index) {
if ($scope.tags[index].id != null) {
return rowform.$cancel()
@ -28,20 +28,20 @@ Application.Controllers.controller('TagsController', ['$scope', 'tagsPromise', '
}
}
// #
// Creates a new empty entry in the $scope.tags array
// #
/**
* Creates a new empty entry in the $scope.tags array
*/
$scope.addTag = function () {
$scope.inserted =
{ name: '' }
return $scope.tags.push($scope.inserted)
}
// #
// Saves a new tag / Update an existing tag to the server (form validation callback)
// @param data {Object} tag name
// @param [data] {number} tag id, in case of update
// #
/**
* Saves a new tag / Update an existing tag to the server (form validation callback)
* @param data {Object} tag name
* @param [data] {number} tag id, in case of update
*/
$scope.saveTag = function (data, id) {
if (id != null) {
return Tag.update({ id }, { tag: data }, response => growl.success(_t('changes_successfully_saved'))
@ -58,10 +58,10 @@ Application.Controllers.controller('TagsController', ['$scope', 'tagsPromise', '
}
}
// #
// Deletes the tag at the specified index
// @param index {number} tag index in the $scope.tags array
// #
/**
* Deletes the tag at the specified index
* @param index {number} tag index in the $scope.tags array
*/
return $scope.removeTag = index =>
// TODO add confirmation : les utilisateurs seront déasociés
Tag.delete({ id: $scope.tags[index].id }, function (resp) {

View File

@ -12,9 +12,9 @@
*/
'use strict'
// #
// Controller used in the public calendar global
// #
/**
* Controller used in the public calendar global
*/
Application.Controllers.controller('CalendarController', ['$scope', '$state', '$aside', 'moment', 'Availability', 'Slot', 'Setting', 'growl', 'dialogs', 'bookingWindowStart', 'bookingWindowEnd', '_t', 'uiCalendarConfig', 'CalendarConfig', 'trainingsPromise', 'machinesPromise', 'spacesPromise',
function ($scope, $state, $aside, moment, Availability, Slot, Setting, growl, dialogs, bookingWindowStart, bookingWindowEnd, _t, uiCalendarConfig, CalendarConfig, trainingsPromise, machinesPromise, spacesPromise) {
@ -24,24 +24,24 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
trainingsPromise.forEach(t => t.checked = true)
spacesPromise.forEach(s => s.checked = true)
// # check all formation/machine is select in filter
// check all formation/machine is select in filter
const isSelectAll = (type, scope) => scope[type].length === scope[type].filter(t => t.checked).length
/* PUBLIC SCOPE */
// # List of trainings
// List of trainings
$scope.trainings = trainingsPromise.filter(t => !t.disabled)
// # List of machines
// List of machines
$scope.machines = machinesPromise.filter(t => !t.disabled)
// # List of spaces
// List of spaces
$scope.spaces = spacesPromise.filter(t => !t.disabled)
// # add availabilities source to event sources
// add availabilities source to event sources
$scope.eventSources = []
// # filter availabilities if have change
// filter availabilities if have change
$scope.filterAvailabilities = function (filter, scope) {
if (!scope) { scope = $scope }
scope.filter = ($scope.filter = {
@ -54,7 +54,7 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
return $scope.calendarConfig.events = availabilitySourceUrl()
}
// # a variable for formation/machine/event/dispo checkbox is or not checked
// a variable for formation/machine/event/dispo checkbox is or not checked
$scope.filter = {
trainings: isSelectAll('trainings', $scope),
machines: isSelectAll('machines', $scope),
@ -63,7 +63,7 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
dispo: true
}
// # toggle to select all formation/machine
// toggle to select all formation/machine
$scope.toggleFilter = function (type, filter) {
$scope[type].forEach(t => t.checked = filter[type])
return $scope.filterAvailabilities(filter, $scope)
@ -115,7 +115,7 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
/* PRIVATE SCOPE */
const calendarEventClickCb = function (event, jsEvent, view) {
// # current calendar object
// current calendar object
const { calendar } = uiCalendarConfig.calendars
if (event.available_type === 'machines') {
currentMachineEvent = event
@ -137,8 +137,8 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
}
}
// # agendaDay view: disable slotEventOverlap
// # agendaWeek view: enable slotEventOverlap
// agendaDay view: disable slotEventOverlap
// agendaWeek view: enable slotEventOverlap
const toggleSlotEventOverlap = function (view) {
// set defaultView, because when we change slotEventOverlap
// ui-calendar will trigger rerender calendar
@ -156,7 +156,7 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
}
}
// # function is called when calendar view is rendered or changed
// function is called when calendar view is rendered or changed
const viewRenderCb = function (view, element) {
toggleSlotEventOverlap(view)
if (view.type === 'agendaDay') {
@ -185,7 +185,7 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
var availabilitySourceUrl = () => `/api/availabilities/public?${$.param(getFilter())}`
const initialize = () =>
// # fullCalendar (v2) configuration
// fullCalendar (v2) configuration
$scope.calendarConfig = CalendarConfig({
events: availabilitySourceUrl(),
slotEventOverlap: true,
@ -208,7 +208,7 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
}
})
// # !!! MUST BE CALLED AT THE END of the controller
// !!! MUST BE CALLED AT THE END of the controller
return initialize()
}
])

View File

@ -13,10 +13,10 @@
'use strict'
Application.Controllers.controller('DashboardController', ['$scope', 'memberPromise', 'SocialNetworks', function ($scope, memberPromise, SocialNetworks) {
// # Current user's profile
// Current user's profile
$scope.user = memberPromise
// # List of social networks associated with this user and toggle 'show all' state
// List of social networks associated with this user and toggle 'show all' state
$scope.social = {
showAllLinks: false,
networks: SocialNetworks
@ -24,16 +24,16 @@ Application.Controllers.controller('DashboardController', ['$scope', 'memberProm
/* PRIVATE SCOPE */
// #
// Kind of constructor: these actions will be realized first when the controller is loaded
// #
/**
* Kind of constructor: these actions will be realized first when the controller is loaded
*/
const initialize = () => $scope.social.networks = filterNetworks()
// #
// Filter social network or website that are associated with the profile of the user provided in promise
// and return the filtered networks
// @return {Array}
// #
/**
* Filter social network or website that are associated with the profile of the user provided in promise
* and return the filtered networks
* @return {Array}
*/
var filterNetworks = function () {
const networks = []
for (let network of Array.from(SocialNetworks)) {
@ -44,7 +44,7 @@ Application.Controllers.controller('DashboardController', ['$scope', 'memberProm
return networks
}
// # !!! MUST BE CALLED AT THE END of the controller
// !!! MUST BE CALLED AT THE END of the controller
return initialize()
}

View File

@ -14,36 +14,36 @@ Application.Controllers.controller('HomeController', ['$scope', '$stateParams',
function ($scope, $stateParams, Twitter, lastMembersPromise, lastProjectsPromise, upcomingEventsPromise, homeBlogpostPromise, twitterNamePromise) {
/* PUBLIC SCOPE */
// # The last registered members who confirmed their addresses
// The last registered members who confirmed their addresses
$scope.lastMembers = lastMembersPromise
// # The last tweets from the Fablab official twitter account
// The last tweets from the Fablab official twitter account
$scope.lastTweets = []
// # The last projects published/documented on the plateform
// The last projects published/documented on the plateform
$scope.lastProjects = lastProjectsPromise
// # The closest upcoming events
// The closest upcoming events
$scope.upcomingEvents = upcomingEventsPromise
// # The admin blogpost
// The admin blogpost
$scope.homeBlogpost = homeBlogpostPromise.setting.value
// # Twitter username
// Twitter username
$scope.twitterName = twitterNamePromise.setting.value
// #
// Test if the provided event run on a single day or not
// @param event {Object} single event from the $scope.upcomingEvents array
// @returns {boolean} false if the event runs on more that 1 day
// #
/**
* Test if the provided event run on a single day or not
* @param event {Object} single event from the $scope.upcomingEvents array
* @returns {boolean} false if the event runs on more that 1 day
*/
$scope.isOneDayEvent = event => moment(event.start_date).isSame(event.end_date, 'day')
/* PRIVATE SCOPE */
// #
// Kind of constructor: these actions will be realized first when the controller is loaded
// #
/**
* Kind of constructor: these actions will be realized first when the controller is loaded
*/
const initialize = function () {
// we retrieve tweets from here instead of ui-router's promise because, if adblock stop the API request,
// this prevent the whole home page to be blocked
@ -56,7 +56,7 @@ Application.Controllers.controller('HomeController', ['$scope', '$stateParams',
}
}
// # !!! MUST BE CALLED AT THE END of the controller
// !!! MUST BE CALLED AT THE END of the controller
return initialize()
}
])

View File

@ -10,11 +10,11 @@
*/
'use strict'
// #
// Navigation controller. List the links availables in the left navigation pane and their icon.
// #
/**
* Navigation controller. List the links availables in the left navigation pane and their icon.
*/
Application.Controllers.controller('MainNavController', ['$scope', '$location', '$cookies', function ($scope, $location, $cookies) {
// # Common links (public application)
// Common links (public application)
$scope.navLinks = [
{
state: 'app.public.home',

View File

@ -13,9 +13,9 @@
*/
'use strict'
// #
// Controller used in the members listing page
// #
/**
* Controller used in the members listing page
*/
Application.Controllers.controller('MembersController', ['$scope', 'Member', 'membersPromise', function ($scope, Member, membersPromise) {
/* PRIVATE STATIC CONSTANTS */
@ -24,19 +24,19 @@ Application.Controllers.controller('MembersController', ['$scope', 'Member', 'me
/* PUBLIC SCOPE */
// # currently displayed page of members
// currently displayed page of members
$scope.page = 1
// # members list
// members list
$scope.members = membersPromise
// true when all members are loaded
$scope.noMoreResults = false
// #
// Callback for the 'load more' button.
// Will load the next results of the current search, if any
// #
/**
* Callback for the 'load more' button.
* Will load the next results of the current search, if any
*/
$scope.showNextMembers = function () {
$scope.page += 1
return Member.query({
@ -54,61 +54,61 @@ Application.Controllers.controller('MembersController', ['$scope', 'Member', 'me
/* PRIVATE SCOPE */
// #
// Kind of constructor: these actions will be realized first when the controller is loaded
// #
/**
* Kind of constructor: these actions will be realized first when the controller is loaded
*/
const initialize = function () {
if (!membersPromise[0] || (membersPromise[0].maxMembers <= $scope.members.length)) {
return $scope.noMoreResults = true
}
}
// # !!! MUST BE CALLED AT THE END of the controller
// !!! MUST BE CALLED AT THE END of the controller
return initialize()
}
])
// #
// Controller used when editing the current user's profile
// #
/**
* Controller used when editing the current user's profile
*/
Application.Controllers.controller('EditProfileController', ['$scope', '$rootScope', '$state', '$window', 'Member', 'Auth', 'Session', 'activeProviderPromise', 'growl', 'dialogs', 'CSRF', 'memberPromise', 'groups', '_t',
function ($scope, $rootScope, $state, $window, Member, Auth, Session, activeProviderPromise, growl, dialogs, CSRF, memberPromise, groups, _t) {
/* PUBLIC SCOPE */
// # API URL where the form will be posted
// API URL where the form will be posted
$scope.actionUrl = `/api/members/${$scope.currentUser.id}`
// # list of groups
// list of groups
$scope.groups = groups.filter(g => !g.disabled)
// # Form action on the above URL
// Form action on the above URL
$scope.method = 'patch'
// # Current user's profile
// Current user's profile
$scope.user = memberPromise
// # default : do not show the group changing form
// default : do not show the group changing form
$scope.group =
{ change: false }
// # group ID of the current/selected user
// group ID of the current/selected user
$scope.userGroup = memberPromise.group_id
// # active authentication provider parameters
// active authentication provider parameters
$scope.activeProvider = activeProviderPromise
// # allow the user to change his password except if he connect from an SSO
// allow the user to change his password except if he connect from an SSO
$scope.preventPassword = false
// # mapping of fields to disable
// mapping of fields to disable
$scope.preventField = {}
// # Should the passord be modified?
// Should the passord be modified?
$scope.password =
{ change: false }
// # Angular-Bootstrap datepicker configuration for birthday
// Angular-Bootstrap datepicker configuration for birthday
$scope.datePicker = {
format: Fablab.uibDateFormat,
opened: false, // default: datePicker is not shown
@ -117,9 +117,9 @@ Application.Controllers.controller('EditProfileController', ['$scope', '$rootSco
}
}
// #
// Return the group object, identified by the ID set in $scope.userGroup
// #
/**
* Return the group object, identified by the ID set in $scope.userGroup
*/
$scope.getUserGroup = function () {
for (let group of Array.from($scope.groups)) {
if (group.id === $scope.userGroup) {
@ -128,9 +128,9 @@ Application.Controllers.controller('EditProfileController', ['$scope', '$rootSco
}
}
// #
// Change the group of the current user to the one set in $scope.userGroup
// #
/**
* Change the group of the current user to the one set in $scope.userGroup
*/
$scope.selectGroup = () =>
Member.update({ id: $scope.user.id }, { user: { group_id: $scope.userGroup } }, function (user) {
$scope.user = user
@ -144,23 +144,23 @@ Application.Controllers.controller('EditProfileController', ['$scope', '$rootSco
return console.error(err)
})
// #
// Callback to diplay the datepicker as a dropdown when clicking on the input field
// @param $event {Object} jQuery event object
// #
/**
* Callback to diplay the datepicker as a dropdown when clicking on the input field
* @param $event {Object} jQuery event object
*/
$scope.openDatePicker = function ($event) {
$event.preventDefault()
$event.stopPropagation()
return $scope.datePicker.opened = true
}
// #
// For use with ngUpload (https://github.com/twilson63/ngUpload).
// Intended to be the callback when the upload is done: any raised error will be stacked in the
// $scope.alerts array. If everything goes fine, the user's profile is updated and the user is
// redirected to the home page
// @param content {Object} JSON - The upload's result
// #
/**
* For use with ngUpload (https://github.com/twilson63/ngUpload).
* Intended to be the callback when the upload is done: any raised error will be stacked in the
* $scope.alerts array. If everything goes fine, the user's profile is updated and the user is
* redirected to the home page
* @param content {Object} JSON - The upload's result
*/
$scope.submited = function (content) {
if ((content.id == null)) {
$scope.alerts = []
@ -184,10 +184,10 @@ Application.Controllers.controller('EditProfileController', ['$scope', '$rootSco
}
}
// #
// Ask for confirmation then delete the current user's account
// @param user {Object} the current user (to delete)
// #
/**
* Ask for confirmation then delete the current user's account
* @param user {Object} the current user (to delete)
*/
$scope.deleteUser = user =>
dialogs.confirm({
resolve: {
@ -212,11 +212,11 @@ Application.Controllers.controller('EditProfileController', ['$scope', '$rootSco
})
)
// #
// For use with 'ng-class', returns the CSS class name for the uploads previews.
// The preview may show a placeholder or the content of the file depending on the upload state.
// @param v {*} any attribute, will be tested for truthiness (see JS evaluation rules)
// #
/**
* For use with 'ng-class', returns the CSS class name for the uploads previews.
* The preview may show a placeholder or the content of the file depending on the upload state.
* @param v {*} any attribute, will be tested for truthiness (see JS evaluation rules)
*/
$scope.fileinputClass = function (v) {
if (v) {
return 'fileinput-exists'
@ -225,18 +225,18 @@ Application.Controllers.controller('EditProfileController', ['$scope', '$rootSco
}
}
// #
// Check if the of the properties editable by the user are linked to the SSO
// @return {boolean} true if some editable fields are mapped with the SSO, false otherwise
// #
/**
* Check if the of the properties editable by the user are linked to the SSO
* @return {boolean} true if some editable fields are mapped with the SSO, false otherwise
*/
$scope.hasSsoFields = () =>
// if check if keys > 1 because there's a minimum of 1 mapping (id <-> provider-uid)
// so the user may want to edit his profile on the SSO if at least 2 mappings exists
Object.keys($scope.preventField).length > 1
// #
// Disconnect and re-connect the user to the SSO to force the synchronisation of the profile's data
// #
/**
* Disconnect and re-connect the user to the SSO to force the synchronisation of the profile's data
*/
$scope.syncProfile = () =>
Auth.logout().then(function (oldUser) {
Session.destroy()
@ -251,9 +251,9 @@ Application.Controllers.controller('EditProfileController', ['$scope', '$rootSco
/* PRIVATE SCOPE */
// #
// Kind of constructor: these actions will be realized first when the controller is loaded
// #
/**
* Kind of constructor: these actions will be realized first when the controller is loaded
*/
const initialize = function () {
CSRF.setMetaTags()
@ -267,19 +267,19 @@ Application.Controllers.controller('EditProfileController', ['$scope', '$rootSco
return angular.forEach(activeProviderPromise.mapping, map => $scope.preventField[map] = true)
}
// # !!! MUST BE CALLED AT THE END of the controller
// !!! MUST BE CALLED AT THE END of the controller
return initialize()
}
])
// #
// Controller used on the public user's profile page (seeing another user's profile)
// #
/**
* Controller used on the public user's profile page (seeing another user's profile)
*/
Application.Controllers.controller('ShowProfileController', ['$scope', 'memberPromise', 'SocialNetworks', function ($scope, memberPromise, SocialNetworks) {
// # Selected user's information
// Selected user's information
$scope.user = memberPromise // DEPENDENCY WITH NAVINUM GAMIFICATION PLUGIN !!!!
// # List of social networks associated with this user and toggle 'show all' state
// List of social networks associated with this user and toggle 'show all' state
$scope.social = {
showAllLinks: false,
networks: SocialNetworks
@ -287,16 +287,16 @@ Application.Controllers.controller('ShowProfileController', ['$scope', 'memberPr
/* PRIVATE SCOPE */
// #
// Kind of constructor: these actions will be realized first when the controller is loaded
// #
/**
* Kind of constructor: these actions will be realized first when the controller is loaded
*/
const initialize = () => $scope.social.networks = filterNetworks()
// #
// Filter social network or website that are associated with the profile of the user provided in promise
// and return the filtered networks
// @return {Array}
// #
/**
* Filter social network or website that are associated with the profile of the user provided in promise
* and return the filtered networks
* @return {Array}
*/
var filterNetworks = function () {
const networks = []
for (let network of Array.from(SocialNetworks)) {
@ -307,7 +307,7 @@ Application.Controllers.controller('ShowProfileController', ['$scope', 'memberPr
return networks
}
// # !!! MUST BE CALLED AT THE END of the controller
// !!! MUST BE CALLED AT THE END of the controller
return initialize()
}

View File

@ -12,10 +12,10 @@
*/
'use strict'
// #
// Controller used in notifications page
// inherits $scope.$parent.notifications (global notifications state) from ApplicationController
// #
/**
* Controller used in notifications page
* inherits $scope.$parent.notifications (global notifications state) from ApplicationController
*/
Application.Controllers.controller('NotificationsController', ['$scope', 'Notification', function ($scope, Notification) {
/* PRIVATE STATIC CONSTANTS */
@ -24,30 +24,30 @@ Application.Controllers.controller('NotificationsController', ['$scope', 'Notifi
/* PUBLIC SCOPE */
// # Array containg the archived notifications (already read)
// Array containg the archived notifications (already read)
$scope.notificationsRead = []
// # Array containg the new notifications (not read)
// Array containg the new notifications (not read)
$scope.notificationsUnread = []
// # Total number of notifications for the current user
// Total number of notifications for the current user
$scope.total = 0
// # Total number of unread notifications for the current user
// Total number of unread notifications for the current user
$scope.totalUnread = 0
// # By default, the pagination mode is activated to limit the page size
// By default, the pagination mode is activated to limit the page size
$scope.paginateActive = true
// # The currently displayed page number
// The currently displayed page number
$scope.page = 1
// #
// Mark the provided notification as read, updating its status on the server and moving it
// to the already read notifications list.
// @param notification {{id:number}} the notification to mark as read
// @param e {Object} see https://docs.angularjs.org/guide/expression#-event-
// #
/**
* Mark the provided notification as read, updating its status on the server and moving it
* to the already read notifications list.
* @param notification {{id:number}} the notification to mark as read
* @param e {Object} see https://docs.angularjs.org/guide/expression#-event-
*/
$scope.markAsRead = function (notification, e) {
e.preventDefault()
return Notification.update({ id: notification.id }, {
@ -66,9 +66,9 @@ Application.Controllers.controller('NotificationsController', ['$scope', 'Notifi
})
}
// #
// Mark every unread notifications as read and move them for the unread list to to read array.
// #
/**
* Mark every unread notifications as read and move them for the unread list to to read array.
*/
$scope.markAllAsRead = () =>
Notification.update({}
, function () { // success
@ -84,10 +84,10 @@ Application.Controllers.controller('NotificationsController', ['$scope', 'Notifi
return $scope.totalUnread = 0
})
// #
// Request the server to retrieve the next notifications and add them
// to their corresponding notifications list (read or unread).
// #
/**
* Request the server to retrieve the next notifications and add them
* to their corresponding notifications list (read or unread).
*/
$scope.addMoreNotifications = function () {
Notification.query({ page: $scope.page }, function (notifications) {
$scope.total = notifications.totals.total
@ -107,12 +107,12 @@ Application.Controllers.controller('NotificationsController', ['$scope', 'Notifi
/* PRIVATE SCOPE */
// #
// Kind of constructor: these actions will be realized first when the controller is loaded
// #
/**
* Kind of constructor: these actions will be realized first when the controller is loaded
*/
const initialize = () => $scope.addMoreNotifications()
// # !!! MUST BE CALLED AT THE END of the controller
// !!! MUST BE CALLED AT THE END of the controller
return initialize()
}
])

View File

@ -15,10 +15,10 @@ Application.Controllers.controller('WalletController', ['$scope', 'walletPromise
function ($scope, walletPromise, transactionsPromise) {
/* PUBLIC SCOPE */
// # current user wallet
// current user wallet
$scope.wallet = walletPromise
// # current wallet transactions
// current wallet transactions
return $scope.transactions = transactionsPromise
}
])

View File

@ -90,9 +90,9 @@ Application.Directives.directive('disableAnimation', ['$animate', ($animate) =>
})
])
// #
// Isolate a form's scope from its parent : no nested validation
// #
/**
* Isolate a form's scope from its parent : no nested validation
*/
Application.Directives.directive('isolateForm', [ () =>
({
restrict: 'A',

View File

@ -148,9 +148,9 @@ Application.Filters.filter('humanize', [ () =>
])
// #
// This filter will convert ASCII carriage-return character to the HTML break-line tag
// #
/**
* This filter will convert ASCII carriage-return character to the HTML break-line tag
*/
Application.Filters.filter('breakFilter', [ () =>
function (text) {
if (text != null) {
@ -160,9 +160,9 @@ Application.Filters.filter('breakFilter', [ () =>
])
// #
// This filter will take a HTML text as input and will return it without the html tags
// #
/**
* This filter will take a HTML text as input and will return it without the html tags
*/
Application.Filters.filter('simpleText', [ () =>
function (text) {
if (text != null) {