Skip to content

Commit

Permalink
update mix application
Browse files Browse the repository at this point in the history
  • Loading branch information
nhathoang989 committed Oct 15, 2023
1 parent d05198e commit 0d46fbf
Show file tree
Hide file tree
Showing 12 changed files with 6,315 additions and 6,222 deletions.
218 changes: 109 additions & 109 deletions src/applications/Mixcore/wwwroot/mix-app/js/app-client.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,51 +201,27 @@ var cart = angular.module("cart", []);
]);
})(window.angular);

modules.component("addToCartButton", {
modules.component("fbCustomerChat", {
templateUrl:
"/mix-app/views/app-client/components/add-to-cart-button/view.html",
"/mix-app/views/app-client/components/fb-customer-chat/view.html",
controller: [
"$location",
function ($location) {
var ctrl = this;
this.$onInit = function () {
setTimeout(() => {
FB.XFBML.parse();
}, 200);
};
},
],
bindings: {
cartData: "=",
propertyId: "=",
title: "=",
imageUrl: "=",
price: "=",
quantity: "=?",
fbPageId: "=",
themeColor: "=",
inGreeting: "=",
outGreeting: "=",
},
controller: "AddToCartController",
});
modules.controller("AddToCartController", [
"$rootScope",
"$scope",
"localStorageService",
function ($rootScope, $scope, localStorageService) {
$scope.init = function () {
$scope.quantity = $scope.quantity || 1;
};
$scope.addToCart = function () {
var current = $rootScope.findObjectByKey(
$scope.cartData.items,
"propertyId",
$scope.propertyId
);
if (current) {
current.quantity += parseInt($scope.quantity);
} else {
var item = {
propertyId: $scope.propertyId,
title: $scope.title,
imageUrl: $scope.imageUrl,
price: $scope.price,
quantity: parseInt($scope.quantity) || 1,
};
$scope.cartData.items.push(item);
$scope.cartData.totalItem += 1;
}
$scope.cartData.total += parseInt($scope.price);
localStorageService.set("shoppingCart", $scope.cartData);
};
},
]);

modules.component("booking", {
templateUrl: "/mix-app/views/app-client/components/booking/index.html",
Expand Down Expand Up @@ -304,27 +280,51 @@ modules.component("booking", {
},
});

modules.component("fbCustomerChat", {
modules.component("addToCartButton", {
templateUrl:
"/mix-app/views/app-client/components/fb-customer-chat/view.html",
controller: [
"$location",
function ($location) {
var ctrl = this;
this.$onInit = function () {
setTimeout(() => {
FB.XFBML.parse();
}, 200);
};
},
],
"/mix-app/views/app-client/components/add-to-cart-button/view.html",
bindings: {
fbPageId: "=",
themeColor: "=",
inGreeting: "=",
outGreeting: "=",
cartData: "=",
propertyId: "=",
title: "=",
imageUrl: "=",
price: "=",
quantity: "=?",
},
controller: "AddToCartController",
});
modules.controller("AddToCartController", [
"$rootScope",
"$scope",
"localStorageService",
function ($rootScope, $scope, localStorageService) {
$scope.init = function () {
$scope.quantity = $scope.quantity || 1;
};
$scope.addToCart = function () {
var current = $rootScope.findObjectByKey(
$scope.cartData.items,
"propertyId",
$scope.propertyId
);
if (current) {
current.quantity += parseInt($scope.quantity);
} else {
var item = {
propertyId: $scope.propertyId,
title: $scope.title,
imageUrl: $scope.imageUrl,
price: $scope.price,
quantity: parseInt($scope.quantity) || 1,
};
$scope.cartData.items.push(item);
$scope.cartData.totalItem += 1;
}
$scope.cartData.total += parseInt($scope.price);
localStorageService.set("shoppingCart", $scope.cartData);
};
},
]);
modules.component("fbLike", {
templateUrl: "/mix-app/views/app-client/components/fb-like/fb-like.html",
Expand Down Expand Up @@ -889,6 +889,57 @@ modules.component("haiyenLoader", {
bindings: {},
});

modules.component("haiyenSubscriber", {
binding: {},
templateUrl:
"/mix-app/views/app-client/components/customs/subscriber/view.html",
controller: [
"$scope",
"$rootScope",
"RestMixDatabaseDataClientService",
function ($scope, $rootScope, service) {
var ctrl = this;
ctrl.subscriber = null;
ctrl.formName = "subscribers";
ctrl.$onInit = async function () {
var initData = await service.initData(ctrl.formName);
if (initData.success) {
ctrl.default = initData.data;
ctrl.subscriber = angular.copy(ctrl.default);
$scope.$apply();
}
};
ctrl.isBusy = false;
ctrl.submit = async function () {
ctrl.isBusy = true;
var result = await service.save(ctrl.subscriber);
if (result.success) {
ctrl.onSuccess(result);
ctrl.subscriber = angular.copy(ctrl.default);
ctrl.isBusy = false;
} else {
ctrl.onFail(result);
ctrl.isBusy = false;
}
$scope.$apply();
};
ctrl.onSuccess = function (result) {
ctrl.msg = {
color: "green",
text: "Cám ơn bạn đã đăng ký thành công!",
};
};

ctrl.onFail = function (result) {
ctrl.msg = {
color: "red",
text: result.errors[0],
};
};
},
],
});

modules.component("tclLogin", {
binding: {
user: "=",
Expand Down Expand Up @@ -953,57 +1004,6 @@ modules.component("tclLogin", {
],
});

modules.component("haiyenSubscriber", {
binding: {},
templateUrl:
"/mix-app/views/app-client/components/customs/subscriber/view.html",
controller: [
"$scope",
"$rootScope",
"RestMixDatabaseDataClientService",
function ($scope, $rootScope, service) {
var ctrl = this;
ctrl.subscriber = null;
ctrl.formName = "subscribers";
ctrl.$onInit = async function () {
var initData = await service.initData(ctrl.formName);
if (initData.success) {
ctrl.default = initData.data;
ctrl.subscriber = angular.copy(ctrl.default);
$scope.$apply();
}
};
ctrl.isBusy = false;
ctrl.submit = async function () {
ctrl.isBusy = true;
var result = await service.save(ctrl.subscriber);
if (result.success) {
ctrl.onSuccess(result);
ctrl.subscriber = angular.copy(ctrl.default);
ctrl.isBusy = false;
} else {
ctrl.onFail(result);
ctrl.isBusy = false;
}
$scope.$apply();
};
ctrl.onSuccess = function (result) {
ctrl.msg = {
color: "green",
text: "Cám ơn bạn đã đăng ký thành công!",
};
};

ctrl.onFail = function (result) {
ctrl.msg = {
color: "red",
text: result.errors[0],
};
};
},
],
});

app.controller("UserController", [
"$rootScope",
"$scope",
Expand Down
Loading

0 comments on commit 0d46fbf

Please sign in to comment.