1313// limitations under the License.
1414import { ContextLevel } from '@/core/constants' ;
1515import { CoreSharedModule } from '@/core/shared.module' ;
16- import { ADDON_BLOG_ENTRY_UPDATED , ADDON_BLOG_SYNC_ID } from '@addons/blog/constants' ;
16+ import { ADDON_BLOG_ENTRY_UPDATED , ADDON_BLOG_SYNC_ID , CoreSiteBlogLevel } from '@addons/blog/constants' ;
1717import {
1818 AddonBlog ,
1919 AddonBlogAddEntryOption ,
@@ -23,7 +23,7 @@ import {
2323 AddonBlogPublishState ,
2424} from '@addons/blog/services/blog' ;
2525import { AddonBlogOffline } from '@addons/blog/services/blog-offline' ;
26- import { Component , ElementRef , OnDestroy , OnInit , ViewChild } from '@angular/core' ;
26+ import { Component , computed , ElementRef , OnDestroy , OnInit , signal , ViewChild } from '@angular/core' ;
2727import { AddonBlogSync } from '@addons/blog/services/blog-sync' ;
2828import { FormControl , FormGroup , Validators } from '@angular/forms' ;
2929import { CoreError } from '@classes/errors/error' ;
@@ -90,6 +90,9 @@ export default class AddonBlogEditEntryPage implements CanLeave, OnInit, OnDestr
9090 siteHomeId ?: number ;
9191 forceLeave = false ;
9292 isOfflineEntry = false ;
93+ readonly blogLevel = signal ( CoreSiteBlogLevel . BLOG_SITE_LEVEL ) ;
94+ readonly isUserLevel = computed ( ( ) => this . blogLevel ( ) === CoreSiteBlogLevel . BLOG_USER_LEVEL ) ;
95+ readonly isGlobalLevel = computed ( ( ) => this . blogLevel ( ) === CoreSiteBlogLevel . BLOG_GLOBAL_LEVEL ) ;
9396
9497 /**
9598 * Gives if the form is not pristine. (only for existing entries)
@@ -132,6 +135,13 @@ export default class AddonBlogEditEntryPage implements CanLeave, OnInit, OnDestr
132135 return CoreNavigator . back ( ) ;
133136 }
134137
138+ const blogLevel = Number ( await site . getConfig ( 'bloglevel' ) ) ;
139+ this . blogLevel . set ( isNaN ( blogLevel ) ? CoreSiteBlogLevel . BLOG_SITE_LEVEL : blogLevel ) ;
140+
141+ if ( this . isUserLevel ( ) ) {
142+ this . form . controls . publishState . setValue ( AddonBlogPublishState . draft ) ;
143+ }
144+
135145 const entryId = CoreNavigator . getRouteParam ( 'id' ) ;
136146 const lastModified = CoreNavigator . getRouteNumberParam ( 'lastModified' ) ;
137147 const filters : AddonBlogFilter | undefined = CoreNavigator . getRouteParam ( 'filters' ) ;
@@ -212,7 +222,7 @@ export default class AddonBlogEditEntryPage implements CanLeave, OnInit, OnDestr
212222 this . entry . summary ,
213223 this . entry . summaryfiles ,
214224 ) ,
215- publishState : this . entry . publishstate ?? AddonBlogPublishState . site ,
225+ publishState : this . entry ? .publishstate ?? AddonBlogPublishState . draft ,
216226 associateWithCourse : this . form . controls . associateWithCourse . value ,
217227 associateWithModule : this . form . controls . associateWithModule . value ,
218228 } ) ;
0 commit comments