Blame view

resources/js/article.js 1.13 KB
e77200db5   nologostudio.ru   Initial commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  import './comment/frCommenter';
  import './common/directives/frMarkdown';
  import './poll/frPoll';
  import './poll/frPollEditorModal';
  
  angular.module('footyroom')
  
  .controller('ArticleEditorController', ['$scope', '$http', '$window', function ($scope, $http, $window) {
      $scope.article = $window.DataStore.article || {
          status: 'draft',
      };
  
      $scope.isPosting = false;
  
      $scope.publish = function () {
          if ($scope.isPosting) {
              return;
          }
  
          $scope.isPosting = true;
  
          $http.post($scope.article.id ? '/articles/' + $scope.article.id : '/articles', {
              title: $scope.article.title,
              content: $scope.article.content,
              thumbnailUrl: $scope.article.thumbnailUrl,
              status: $scope.article.status,
              isFeatured: $scope.article.isFeatured,
          })
  
          .then(function (response) {
              window.localStorage.removeItem('markdownContent');
              $window.location = response.data.url;
          })
  
          .catch(function (response) {
              $scope.isPosting = false;
              $scope.errors = response.data.errors;
          });
      };
  }]);