@ -24,6 +24,7 @@ import {cssButton} from 'app/client/ui2018/buttons';
import { icon } from 'app/client/ui2018/icons' ;
import { confirmModal } from 'app/client/ui2018/modals' ;
import { INITIAL_FIELDS_COUNT } from 'app/common/Forms' ;
import { isOwner } from 'app/common/roles' ;
import { Events as BackboneEvents } from 'backbone' ;
import { Computed , dom , Holder , IDomArgs , MultiHolder , Observable } from 'grainjs' ;
import defaults from 'lodash/defaults' ;
@ -58,6 +59,7 @@ export class FormView extends Disposable {
private _remoteShare : AsyncComputed < { key : string } | null > ;
private _published : Computed < boolean > ;
private _showPublishedMessage : Observable < boolean > ;
private _isOwner : boolean ;
public create ( gristDoc : GristDoc , viewSectionModel : ViewSectionRec ) {
BaseView . call ( this as any , gristDoc , viewSectionModel , { 'addNewRow' : false } ) ;
@ -380,6 +382,8 @@ export class FormView extends Disposable {
true
) ) ;
this . _isOwner = isOwner ( this . gristDoc . docPageModel . currentDoc . get ( ) ) ;
// Last line, build the dom.
this . viewPane = this . autoDispose ( this . buildDom ( ) ) ;
}
@ -640,7 +644,7 @@ export class FormView extends Disposable {
testId ( 'link' ) ,
dom ( 'div' , 'Copy Link' ) ,
dom . prop ( 'disabled' , this . _copyingLink ) ,
dom . show ( use = > this . gristDoc. appModel . isOwner ( ) && use ( this . _published ) ) ,
dom . show ( use = > this . _isOwner && use ( this . _published ) ) ,
dom . on ( 'click' , async ( _event , element ) = > {
try {
this . _copyingLink . set ( true ) ;
@ -662,14 +666,14 @@ export class FormView extends Disposable {
return published
? style . cssIconButton (
dom ( 'div' , 'Unpublish' ) ,
dom . show ( this . gristDoc. appModel . isOwner ( ) ) ,
dom . show ( this . _isOwner ) ,
style . cssIconButton . cls ( '-warning' ) ,
dom . on ( 'click' , ( ) = > this . _handleClickUnpublish ( ) ) ,
testId ( 'unpublish' ) ,
)
: style . cssIconButton (
dom ( 'div' , 'Publish' ) ,
dom . show ( this . gristDoc. appModel . isOwner ( ) ) ,
dom . show ( this . _isOwner ) ,
cssButton . cls ( '-primary' ) ,
dom . on ( 'click' , ( ) = > this . _handleClickPublish ( ) ) ,
testId ( 'publish' ) ,
@ -714,7 +718,7 @@ export class FormView extends Disposable {
this . _showPublishedMessage . set ( false ) ;
} ) ,
) ,
dom . show ( this . gristDoc. appModel . isOwner ( ) ) ,
dom . show ( this . _isOwner ) ,
) ;
} ) ;
}