Add api/shops_controller and refactor

This commit is contained in:
Matt-Yorkley
2020-04-04 16:28:04 +02:00
parent af48cac140
commit bc859cf9f7
11 changed files with 87 additions and 69 deletions

View File

@@ -24,7 +24,7 @@ Darkswarm.controller "HubNodeCtrl", ($scope, HashNavigation, CurrentHub, $http,
$scope.shopfront_loading = true
$scope.toggle_tab(event)
$http.get("/api/enterprises/" + $scope.hub.id + "/shopfront")
$http.get("/api/shops/" + $scope.hub.id)
.success (data) ->
$scope.shopfront_loading = false
$scope.hub = data

View File

@@ -24,7 +24,7 @@ Darkswarm.controller "ProducerNodeCtrl", ($scope, HashNavigation, $anchorScroll,
$scope.shopfront_loading = true
$scope.toggle_tab(event)
$http.get("/api/enterprises/" + $scope.producer.id + "/shopfront")
$http.get("/api/shops/" + $scope.producer.id)
.success (data) ->
$scope.shopfront_loading = false
$scope.producer = data

View File

@@ -5,7 +5,7 @@ Darkswarm.factory "EnterpriseModal", ($modal, $rootScope, $http)->
scope = $rootScope.$new(true) # Spawn an isolate to contain the enterprise
scope.embedded_layout = window.location.search.indexOf("embedded_shopfront=true") != -1
$http.get("/api/enterprises/" + enterprise.id + "/shopfront").success (data) ->
$http.get("/api/shops/" + enterprise.id).success (data) ->
scope.enterprise = data
$modal.open(templateUrl: "enterprise_modal.html", scope: scope)
.error (data) ->

View File

@@ -5,8 +5,4 @@ Darkswarm.factory 'EnterpriseResource', ($resource) ->
url: '/enterprises/:id/relatives.json'
isArray: true
cache: true
'closed_shops':
method: 'GET'
isArray: true
url: '/api/enterprises/closed_shops.json'
})

View File

@@ -1,4 +1,4 @@
Darkswarm.factory 'Enterprises', (enterprises, EnterpriseResource, CurrentHub, Taxons, Dereferencer, Matcher, Geo, $rootScope) ->
Darkswarm.factory 'Enterprises', (enterprises, ShopsResource, CurrentHub, Taxons, Dereferencer, Matcher, Geo, $rootScope) ->
new class Enterprises
enterprises: []
enterprises_by_id: {}
@@ -46,7 +46,7 @@ Darkswarm.factory 'Enterprises', (enterprises, EnterpriseResource, CurrentHub, T
@enterprises_by_id[enterprise.id] = enterprise
loadClosedEnterprises: ->
request = EnterpriseResource.closed_shops {}, (data) =>
request = ShopsResource.closed_shops {}, (data) =>
@initEnterprises(data)
request.$promise

View File

@@ -0,0 +1,7 @@
Darkswarm.factory 'ShopsResource', ($resource) ->
$resource('/api/shops/:id.json', {}, {
'closed_shops':
method: 'GET'
isArray: true
url: '/api/shops/closed_shops.json'
})