Skip to content
Extraits de code Groupes Projets
Valider de260c86 rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

refs #6284 converted some directive controllers to use controllerAs. Initially...

refs #6284 converted some directive controllers to use controllerAs. Initially I converted nearly of them but noticed it does not always make sense for directive controller so I revert most changes again. For regular controllers it still makes sense which we will use when using ngRoute
parent eaf702fe
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 71 ajouts et 53 suppressions
......@@ -9,19 +9,25 @@
RateFeatureController.$inject = ['$scope', 'rateFeatureModel'];
function RateFeatureController($scope, rateFeatureModel){
function RateFeatureController($scope, model){
$scope.dislikeFeature = function () {
$scope.like = false;
var vm = this;
vm.title = $scope.title;
vm.dislikeFeature = dislikeFeature;
vm.likeFeature = likeFeature;
vm.sendFeedback = sendFeedback;
function dislikeFeature () {
vm.like = false;
};
$scope.likeFeature = function () {
$scope.like = true;
function likeFeature () {
vm.like = true;
};
$scope.sendFeedback = function (message) {
rateFeatureModel.sendFeedbackForFeature($scope.title, $scope.like, message);
$scope.ratingDone = true;
function sendFeedback (message) {
model.sendFeedbackForFeature(vm.title, vm.like, message);
vm.ratingDone = true;
};
}
})();
<div title="{{ 'Feedback_RateFeatureTitle'|translate:title }}" class="ratefeature">
<div title="{{ 'Feedback_RateFeatureTitle'|translate:rateFeature.title }}" class="ratefeature">
<div class="iconContainer"
ng-mouseenter="view.expanded=true;"
ng-mouseleave="view.expanded=false">
<img ng-click="likeFeature();view.showFeedbackForm=true;"
<img ng-click="rateFeature.likeFeature();view.showFeedbackForm=true;"
class="like-icon"
src="plugins/Feedback/angularjs/ratefeature/thumbs-up.png"/>
<img ng-click="dislikeFeature();view.showFeedbackForm=true;"
<img ng-click="rateFeature.dislikeFeature();view.showFeedbackForm=true;"
class="dislike-icon"
ng-show="view.expanded"
src="plugins/Feedback/angularjs/ratefeature/thumbs-down.png"/>
</div>
<div class="ui-confirm ratefeatureDialog" piwik-dialog="view.showFeedbackForm" yes="sendFeedback(view.feedbackMessage)">
<div class="ui-confirm ratefeatureDialog" piwik-dialog="view.showFeedbackForm" yes="rateFeature.sendFeedback(view.feedbackMessage)">
<h2>{{ 'Feedback_RateFeatureThankYouTitle'|translate:title }}</h2>
<p ng-if="like">{{ 'Feedback_RateFeatureLeaveMessageLike'|translate }}</p>
<p ng-if="!like">{{ 'Feedback_RateFeatureLeaveMessageDislike'|translate }}</p>
<p ng-if="rateFeature.like">{{ 'Feedback_RateFeatureLeaveMessageLike'|translate }}</p>
<p ng-if="!rateFeature.like">{{ 'Feedback_RateFeatureLeaveMessageDislike'|translate }}</p>
<br />
<div class="messageContainer">
......@@ -29,8 +29,8 @@
value="{{ 'Feedback_SendFeedback'|translate }}" role="yes"/>
</div>
<div class="ui-confirm ratefeatureDialog" piwik-dialog="ratingDone" yes="">
<h2>{{ 'Feedback_ThankYou'|translate:title }}</h2>
<div class="ui-confirm ratefeatureDialog" piwik-dialog="rateFeature.ratingDone" yes="">
<h2>{{ 'Feedback_ThankYou'|translate:rateFeature.title }}</h2>
<input type="button" value="{{ 'General_Ok'|translate }}" role="yes"/>
</div>
......
......@@ -22,7 +22,8 @@
title: '@'
},
templateUrl: 'plugins/Feedback/angularjs/ratefeature/ratefeature.directive.html?cb=' + piwik.cacheBuster,
controller: 'RateFeatureController'
controller: 'RateFeatureController',
controllerAs: 'rateFeature',
};
}
})();
\ No newline at end of file
......@@ -7,11 +7,12 @@
(function () {
angular.module('piwikApp').controller('TranslationSearchController', TranslationSearchController);
TranslationSearchController.$inject = ['$scope', 'piwikApi'];
TranslationSearchController.$inject = ['piwikApi'];
function TranslationSearchController($scope, piwikApi) {
function TranslationSearchController(piwikApi) {
$scope.existingTranslations = [];
var vm = this;
vm.existingTranslations = [];
fetchTranslations();
......@@ -21,7 +22,7 @@
languageCode: 'en'
}).then(function (response) {
if (response) {
$scope.existingTranslations = response;
vm.existingTranslations = response;
}
});
}
......
......@@ -6,12 +6,12 @@
Enter a search term to find translations and their corresponding keys:
</p>
<input type="text" placeholder="Search for English translation" title="Search for English translation. Max 1000 results will be shown." ng-model="view.searchTerm" style="width:271px">
<input type="text" placeholder="Search for English translation" title="Search for English translation. Max 1000 results will be shown." ng-model="translationSearch.searchTerm" style="width:271px">
<br />
<br />
<table ng-show="view.searchTerm" class="entityTable dataTable" style="width: 800px;word-break: break-all;">
<table ng-show="translationSearch.searchTerm" class="entityTable dataTable" style="width: 800px;word-break: break-all;">
<thead>
<tr>
<th style="width:250px;">Key</th>
......@@ -19,7 +19,7 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="translation in existingTranslations | filter:view.searchTerm | limitTo: 1000">
<tr ng-repeat="translation in translationSearch.existingTranslations | filter:translationSearch.searchTerm | limitTo: 1000">
<td>{{ translation.label }}</td>
<td>{{ translation.value }}</td>
</tr>
......
......@@ -24,7 +24,8 @@
restrict: 'A',
scope: {},
templateUrl: 'plugins/LanguagesManager/angularjs/translationsearch/translationsearch.directive.html?cb=' + piwik.cacheBuster,
controller: 'TranslationSearchController'
controller: 'TranslationSearchController',
controllerAs: 'translationSearch'
};
}
})();
\ No newline at end of file
......@@ -76,6 +76,7 @@ class MultiSites extends \Piwik\Plugin
$jsFiles[] = "plugins/MultiSites/angularjs/dashboard/dashboard.controller.js";
$jsFiles[] = "plugins/MultiSites/angularjs/dashboard/dashboard-group.filter.js";
$jsFiles[] = "plugins/MultiSites/angularjs/dashboard/dashboard.directive.js";
$jsFiles[] = "plugins/MultiSites/angularjs/site/site.controller.js";
$jsFiles[] = "plugins/MultiSites/angularjs/site/site.directive.js";
}
......
/*!
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
(function () {
angular.module('piwikApp').controller('MultiSitesSiteController', MultiSitesSiteController);
MultiSitesSiteController.$inject = ['$scope', 'piwik'];
function MultiSitesSiteController($scope, piwik){
$scope.period = piwik.period;
$scope.date = piwik.broadcast.getValueFromUrl('date');
$scope.sparklineImage = sparklineImage;
this.getWebsite = function () {
return $scope.website;
};
function sparklineImage(website){
var append = '';
var token_auth = piwik.broadcast.getValueFromUrl('token_auth');
if (token_auth.length) {
append = '&token_auth=' + token_auth;
}
return piwik.piwik_url + '?module=MultiSites&action=getEvolutionGraph&period=' + $scope.period + '&date=' + $scope.dateSparkline + '&evolutionBy=' +$scope.metric + '&columns=' + $scope.metric + '&idSite=' + website.idsite + '&idsite=' + website.idsite + '&viewDataTable=sparkline' + append + '&colors=' + encodeURIComponent(JSON.stringify(piwik.getSparklineColors()));
};
}
})();
......@@ -36,25 +36,7 @@
metric: '='
},
templateUrl: 'plugins/MultiSites/angularjs/site/site.directive.html?cb=' + piwik.cacheBuster,
controller: function ($scope) {
$scope.period = piwik.period;
$scope.date = piwik.broadcast.getValueFromUrl('date');
this.getWebsite = function () {
return $scope.website;
};
$scope.sparklineImage = function(website){
var append = '';
var token_auth = piwik.broadcast.getValueFromUrl('token_auth');
if (token_auth.length) {
append = '&token_auth=' + token_auth;
}
return piwik.piwik_url + '?module=MultiSites&action=getEvolutionGraph&period=' + $scope.period + '&date=' + $scope.dateSparkline + '&evolutionBy=' +$scope.metric + '&columns=' + $scope.metric + '&idSite=' + website.idsite + '&idsite=' + website.idsite + '&viewDataTable=sparkline' + append + '&colors=' + encodeURIComponent(JSON.stringify(piwik.getSparklineColors()));
};
}
controller: 'MultiSitesSiteController'
};
}
})();
\ No newline at end of file
......@@ -10,9 +10,7 @@
CoreAPIFactory.$inject = ['sitesManagerApiHelper'];
function CoreAPIFactory(sitesManagerApiHelper) {
var api = sitesManagerApiHelper;
function CoreAPIFactory(api) {
return {
getIpFromHeader: getIpFromHeader()
......
......@@ -10,9 +10,7 @@
CoreAdminAPIFactory.$inject = ['sitesManagerApiHelper'];
function CoreAdminAPIFactory(sitesManagerApiHelper) {
var api = sitesManagerApiHelper;
function CoreAdminAPIFactory(api) {
return {
isPluginActivated: isPluginActivated()
......
......@@ -9,9 +9,7 @@
SitesManagerAPIFactory.$inject = ['sitesManagerApiHelper'];
function SitesManagerAPIFactory(sitesManagerApiHelper) {
var api = sitesManagerApiHelper;
function SitesManagerAPIFactory(api) {
return {
getCurrencyList: getCurrencyList(),
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter