22 $scope . vm = { } ;
33 $scope . itemToPurge = { } ;
44 $scope . security = $rootScope . security ;
5- $scope . pager = { } ;
6- $scope . pager . items = [ ] ;
7- $scope . pagerCurrentPage = 0 ;
85 $scope . focusInput = false ;
6+ $scope . qd = angular . copy ( newDraft ) ;
7+
8+ $scope . postDraft = function ( ) {
9+ var draft = {
10+ "Id" : "" ,
11+ "Title" : $scope . qd . title ,
12+ "Author" : "" ,
13+ "Content" : $scope . qd . text ,
14+ "DateCreated" : moment ( ) . format ( "YYYY-MM-DD HH:mm" ) ,
15+ "Slug" : "" ,
16+ "Categories" : "" ,
17+ "Tags" : "" ,
18+ "Comments" : "" ,
19+ "HasCommentsEnabled" : true ,
20+ "IsPublished" : false
21+ }
22+ dataService . addItem ( 'api/posts' , draft )
23+ . success ( function ( data ) {
24+ $scope . qd = angular . copy ( newDraft ) ;
25+ var dft = {
26+ "IsChecked" : false ,
27+ "Id" : data . Id ,
28+ "Title" : data . Title ,
29+ "Author" : data . Author ,
30+ "DateCreated" : data . DateCreated ,
31+ "Slug" : data . Slug ,
32+ "RelativeLink" : data . RelativeLink ,
33+ "Categories" : null ,
34+ "Tags" : null ,
35+ "Comments" : null ,
36+ "IsPublished" : false
37+ } ;
38+ $scope . vm . DraftPosts . push ( dft ) ;
39+ toastr . success ( $rootScope . lbl . postAdded ) ;
40+ } )
41+ . error ( function ( ) { toastr . error ( $rootScope . lbl . failedAddingNewPost ) ; } ) ;
42+ }
943
1044 $scope . openLogFile = function ( ) {
1145 $ ( "#modal-log-file" ) . modal ( ) ;
84118 dataService . getItems ( '/api/dashboard' )
85119 . success ( function ( data ) {
86120 angular . copy ( data , $scope . vm ) ;
87- $scope . pager . items = $scope . vm . Notes ;
88- listPagerInit ( $scope . pager ) ;
89121 } )
90122 . error ( function ( data ) { toastr . success ( $rootScope . lbl . errorGettingStats ) ; } ) ;
91123 }
92-
93124 $scope . loadPackages = function ( ) {
94125 if ( ! $scope . security . showTabCustom ) {
95126 return ;
108139 toastr . error ( $rootScope . lbl . errorLoadingPackages ) ;
109140 } ) ;
110141 }
111-
112142 $scope . checkNewVersion = function ( ) {
113143 if ( ! $scope . security . showTabCustom ) {
114144 return ;
129159 }
130160
131161 $scope . load ( ) ;
162+ } ] ) ;
132163
133- $scope . noteId = '' ;
134- $scope . notePage = 1 ;
135- $scope . addNote = function ( ) {
136- $scope . noteId = '' ;
137- $ ( "#txtAddNote" ) . val ( '' ) ;
138- $ ( "#modal-add-note" ) . modal ( ) ;
139- $scope . focusInput = true ;
140- }
141- $scope . editNote = function ( id ) {
142- $scope . noteId = id ;
143- var note = findInArray ( $scope . pager . items , 'Id' , id ) ;
144- $ ( "#txtEditNote" ) . val ( note . Note ) ;
145- $ ( "#modal-edit-note" ) . modal ( ) ;
146- $scope . focusInput = true ;
147- }
148- $scope . deleteNote = function ( id ) {
149- var note = { 'Id' : id } ;
150- dataService . deleteItem ( "/api/quicknotes/" , note )
151- . success ( function ( data ) {
152- toastr . success ( $rootScope . lbl . completed ) ;
153- $scope . load ( ) ;
154- $ ( "#modal-edit-note" ) . modal ( 'hide' ) ;
155- } )
156- . error ( function ( ) {
157- toastr . error ( $rootScope . lbl . failed ) ;
158- $ ( "#modal-edit-note" ) . modal ( 'hide' ) ;
159- } ) ;
160- }
161- saveNote = function ( ) {
162- if ( $scope . noteId === '' ) {
163- $scope . addNewNote ( ) ;
164- }
165- else {
166- $scope . updateNote ( ) ;
167- }
168- $scope . focusInput = false ;
169- }
170- $scope . addNewNote = function ( ) {
171- if ( $ ( "#txtAddNote" ) . val ( ) . length < 1 ) {
172- toastr . error ( $rootScope . lbl . isRequiredField ) ;
173- return false ;
174- }
175- var note = { 'Id' : '' , 'Note' : $ ( "#txtAddNote" ) . val ( ) } ;
176- dataService . addItem ( "/api/quicknotes/add" , note )
177- . success ( function ( data ) {
178- toastr . success ( $rootScope . lbl . completed ) ;
179- $scope . load ( ) ;
180- $ ( "#modal-add-note" ) . modal ( 'hide' ) ;
181- } )
182- . error ( function ( ) {
183- toastr . error ( $rootScope . lbl . failed ) ;
184- $ ( "#modal-add-note" ) . modal ( 'hide' ) ;
185- } ) ;
186- }
187- $scope . updateNote = function ( ) {
188- if ( $ ( "#txtEditNote" ) . val ( ) . length < 1 ) {
189- toastr . error ( $rootScope . lbl . isRequiredField ) ;
190- return false ;
191- }
192- var note = { 'Id' : $scope . noteId , 'Note' : $ ( "#txtEditNote" ) . val ( ) } ;
193- dataService . updateItem ( "/api/quicknotes/" + $scope . noteId , note )
194- . success ( function ( data ) {
195- toastr . success ( $rootScope . lbl . completed ) ;
196- $scope . load ( ) ;
197- $ ( "#modal-edit-note" ) . modal ( 'hide' ) ;
198- } )
199- . error ( function ( ) {
200- toastr . error ( $rootScope . lbl . failed ) ;
201- $ ( "#modal-edit-note" ) . modal ( 'hide' ) ;
202- } ) ;
203- }
204- $scope . notePrevPage = function ( ) {
205- if ( $scope . notePage > 1 ) {
206- $scope . notePage -- ;
207- }
208- alert ( $scope . notePage ) ;
209- }
210- $scope . noteNextPage = function ( ) {
211- $scope . notePage ++ ;
212- alert ( $scope . notePage ) ;
213- }
214-
215- } ] ) ;
164+ var newDraft = {
165+ show : UserVars . Rights . indexOf ( "CreateNewPosts" ) > 0 ,
166+ title : "" ,
167+ text : ""
168+ }
0 commit comments