Skip to content

Commit

Permalink
Restyled by prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits committed Sep 15, 2023
1 parent e57e556 commit 9b5750b
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
app.component("themeImportCultures", {
templateUrl :
"/mix-app/views/app-portal/pages/theme-import/components/theme-import-cultures/view.html",
controller : [
templateUrl:
"/mix-app/views/app-portal/pages/theme-import/components/theme-import-cultures/view.html",
controller: [
"$rootScope",
"$scope",
"ngAppSettings",
function($rootScope, $scope, ngAppSettings) {
function ($rootScope, $scope, ngAppSettings) {
var ctrl = this;
var service = $rootScope.getRestService("culture");
ctrl.selectAllContent = false;
ctrl.request = angular.copy(ngAppSettings.request);
ctrl.$onInit = async () => { ctrl.getList(); };
ctrl.$onInit = async () => {
ctrl.getList();
};
ctrl.getList = async (cultureIndex) => {
if (cultureIndex !== undefined) {
ctrl.request.cultureIndex = cultureIndex;
Expand All @@ -32,29 +34,36 @@
ctrl.selectAllContent = ctrl.selectAllContent && selected;
ctrl.selectAllData = ctrl.selectAllData && selected;
culture.isImportData = selected && culture.isImportData;
ctrl.updateContent([ culture.id ], selected);
ctrl.updateContent([culture.id], selected);
};
ctrl.updateContent = function(arr, selected) {
ctrl.updateContent = function (arr, selected) {
if (selected) {
ctrl.importThemeDto.cultureIds =
ctrl.unionArray(ctrl.importThemeDto.cultureIds, arr);
ctrl.importThemeDto.cultureIds = ctrl.unionArray(
ctrl.importThemeDto.cultureIds,
arr,
);
} else {
ctrl.importThemeDto.cultureIds =
ctrl.importThemeDto.cultureIds.filter((m) => arr.indexOf(m) < 0);
ctrl.importThemeDto.cultureIds.filter((m) => arr.indexOf(m) < 0);
ctrl.updateData(arr, false);
}
};
ctrl.selectAll = function(arr) {
ctrl.selectAll = function (arr) {
// ctrl.selectedList.data = [];
var ids = arr.map(function(obj) { return obj.id; });
var ids = arr.map(function (obj) {
return obj.id;
});
ctrl.updateContent(ids, ctrl.selectAllContent);
angular.forEach(arr,
function(e) { e.isActived = ctrl.selectAllContent; });
angular.forEach(arr, function (e) {
e.isActived = ctrl.selectAllContent;
});
};
ctrl.unionArray = (a, b) => {
return [...new Set([...a, ...b])];
};
ctrl.unionArray = (a, b) => { return [...new Set([...a, ...b ]) ]; };
},
],
bindings : {
importThemeDto : "=",
bindings: {
importThemeDto: "=",
},
});
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
app.component("themeExportCultures", {
templateUrl :
"/mix-app/views/app-portal/pages/theme/components/theme-export-cultures/view.html",
controller : [
templateUrl:
"/mix-app/views/app-portal/pages/theme/components/theme-export-cultures/view.html",
controller: [
"$rootScope",
"$scope",
"ngAppSettings",
function($rootScope, $scope, ngAppSettings) {
function ($rootScope, $scope, ngAppSettings) {
var ctrl = this;
var service = $rootScope.getRestService("culture");
ctrl.selectAllContent = false;
ctrl.request = angular.copy(ngAppSettings.request);
ctrl.$onInit = async () => { ctrl.getList(); };
ctrl.$onInit = async () => {
ctrl.getList();
};
ctrl.getList = async (cultureIndex) => {
if (cultureIndex !== undefined) {
ctrl.request.cultureIndex = cultureIndex;
Expand All @@ -32,29 +34,36 @@
ctrl.selectAllContent = ctrl.selectAllContent && selected;
ctrl.selectAllData = ctrl.selectAllData && selected;
culture.isExportData = selected && culture.isExportData;
ctrl.updateContent([ culture.id ], selected);
ctrl.updateContent([culture.id], selected);
};
ctrl.updateContent = function(arr, selected) {
ctrl.updateContent = function (arr, selected) {
if (selected) {
ctrl.exportThemeDto.cultureIds =
ctrl.unionArray(ctrl.exportThemeDto.cultureIds, arr);
ctrl.exportThemeDto.cultureIds = ctrl.unionArray(
ctrl.exportThemeDto.cultureIds,
arr,
);
} else {
ctrl.exportThemeDto.cultureIds =
ctrl.exportThemeDto.cultureIds.filter((m) => arr.indexOf(m) < 0);
ctrl.exportThemeDto.cultureIds.filter((m) => arr.indexOf(m) < 0);
ctrl.updateData(arr, false);
}
};
ctrl.selectAll = function(arr) {
ctrl.selectAll = function (arr) {
// ctrl.selectedList.data = [];
var ids = arr.map(function(obj) { return obj.id; });
var ids = arr.map(function (obj) {
return obj.id;
});
ctrl.updateContent(ids, ctrl.selectAllContent);
angular.forEach(arr,
function(e) { e.isActived = ctrl.selectAllContent; });
angular.forEach(arr, function (e) {
e.isActived = ctrl.selectAllContent;
});
};
ctrl.unionArray = (a, b) => {
return [...new Set([...a, ...b])];
};
ctrl.unionArray = (a, b) => { return [...new Set([...a, ...b ]) ]; };
},
],
bindings : {
exportThemeDto : "=",
bindings: {
exportThemeDto: "=",
},
});
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
app.component("themeExportPosts", {
templateUrl :
"/mix-app/views/app-portal/pages/theme/components/theme-export-posts/view.html",
controller : [
templateUrl:
"/mix-app/views/app-portal/pages/theme/components/theme-export-posts/view.html",
controller: [
"$rootScope",
"$scope",
"ngAppSettings",
"BaseRestService",
function($rootScope, $scope, ngAppSettings, baseRestService) {
function ($rootScope, $scope, ngAppSettings, baseRestService) {
var ctrl = this;
var service = angular.copy(baseRestService);
service.initService("/rest/mix-portal", "mix-post");
Expand Down Expand Up @@ -38,44 +38,61 @@
ctrl.selectAllContent = ctrl.selectAllContent && selected;
ctrl.selectAllData = ctrl.selectAllData && selected;
post.isExportData = selected && post.isExportData;
let contentIds = post.contents.map(function(obj) { return obj.id; });
let contentIds = post.contents.map(function (obj) {
return obj.id;
});
ctrl.exportThemeDto.content.postIds = ctrl.updateArray(
ctrl.exportThemeDto.content.postIds, [ post.id ], selected);
ctrl.exportThemeDto.content.postIds,
[post.id],
selected,
);
ctrl.exportThemeDto.content.postContentIds = ctrl.updateArray(
ctrl.exportThemeDto.content.postContentIds, contentIds, selected);
ctrl.exportThemeDto.content.postContentIds,
contentIds,
selected,
);
if (!selected) {
ctrl.selectData(post, false);
}
};
ctrl.selectData = (post, selected) => {
ctrl.selectAllData = ctrl.selectAllData && selected;
let contentIds = post.contents.map(function(obj) { return obj.id; });
let contentIds = post.contents.map(function (obj) {
return obj.id;
});
ctrl.exportThemeDto.associations.postIds = ctrl.updateArray(
ctrl.exportThemeDto.associations.postIds, [ post.id ], selected);
ctrl.exportThemeDto.associations.postContentIds =
ctrl.updateArray(ctrl.exportThemeDto.associations.postContentIds,
contentIds, selected);
ctrl.exportThemeDto.associations.postIds,
[post.id],
selected,
);
ctrl.exportThemeDto.associations.postContentIds = ctrl.updateArray(
ctrl.exportThemeDto.associations.postContentIds,
contentIds,
selected,
);
};
ctrl.updateArray = function(src, arr, selected) {
ctrl.updateArray = function (src, arr, selected) {
if (selected) {
src = ctrl.unionArray(src, arr);
} else {
src = src.filter((m) => arr.indexOf(m) < 0);
}
return src;
};
ctrl.selectAll = function(arr) {
angular.forEach(arr, function(e) {
ctrl.selectAll = function (arr) {
angular.forEach(arr, function (e) {
ctrl.selectContent(e, ctrl.selectAllContent);
ctrl.selectData(e, ctrl.selectAllData);
e.isActived = ctrl.selectAllContent;
e.isExportData = ctrl.selectAllData;
});
};
ctrl.unionArray = (a, b) => { return [...new Set([...a, ...b ]) ]; };
ctrl.unionArray = (a, b) => {
return [...new Set([...a, ...b])];
};
},
],
bindings : {
exportThemeDto : "=",
bindings: {
exportThemeDto: "=",
},
});
10 changes: 5 additions & 5 deletions src/app/app-portal/pages/url-alias/url-alias-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ app.factory("UrlAliasService", [
"ApiService",
"CommonService",
"BaseRestService",
function($rootScope, apiService, commonService, baseService) {
function ($rootScope, apiService, commonService, baseService) {
var serviceFactory = Object.create(baseService);
serviceFactory.initService("/rest/mix-portal", "mix-url-alias");

var _updateInfos = async function(pages) {
var _updateInfos = async function (pages) {
var req = {
method : "POST",
url : this.prefixUrl + "/update-infos",
data : JSON.stringify(pages),
method: "POST",
url: this.prefixUrl + "/update-infos",
data: JSON.stringify(pages),
};
return await apiService.sendRequest(req);
};
Expand Down

0 comments on commit 9b5750b

Please sign in to comment.