@@ -83,48 +83,51 @@ export function createWebProperty(...args: any) {
8383 body : payload ,
8484 } )
8585 . then ( ( r ) => {
86- if ( indexed ) {
87- $pnp . sp . web . allProperties . select ( 'vti_indexedpropertykeys' ) ( ) . then ( result => {
88-
89- const allProps = [ ]
90- for ( let prop in result ) {
91- if ( prop && prop !== 'odata.metadata' && prop !== '__metadata' && prop !== 'odata.editLink' && prop !== 'odata.id' && prop !== 'odata.type' ) {
92-
93- const re = / _ x .* ?_ / g
94- const found = prop . match ( re )
95- const origKey = prop
96-
97- if ( found !== null )
98- for ( const g in found ) {
99- if ( g ) {
100- const unesc = found [ g ] . replace ( '_x' , '%u' ) . replace ( '_' , '' )
101- prop = prop . replace ( found [ g ] , unescape ( unesc ) )
102- }
86+ // if (indexed) {
87+ $pnp . sp . web . allProperties . select ( 'vti_indexedpropertykeys' ) ( ) . then ( result => {
88+
89+ const allProps = [ ]
90+ for ( let prop in result ) {
91+ if ( prop && prop !== 'odata.metadata' && prop !== '__metadata' && prop !== 'odata.editLink' && prop !== 'odata.id' && prop !== 'odata.type' ) {
92+
93+ const re = / _ x .* ?_ / g
94+ const found = prop . match ( re )
95+ const origKey = prop
96+
97+ if ( found !== null )
98+ for ( const g in found ) {
99+ if ( g ) {
100+ const unesc = found [ g ] . replace ( '_x' , '%u' ) . replace ( '_' , '' )
101+ prop = prop . replace ( found [ g ] , unescape ( unesc ) )
103102 }
104- allProps . push ( { key : prop . replace ( / O D a t a _ / g , '' ) , value : result [ origKey ] } )
105- }
103+ }
104+ allProps . push ( { key : prop . replace ( / O D a t a _ / g , '' ) , value : result [ origKey ] } )
106105 }
107-
108- const bytes = [ ]
109- for ( let i = 0 ; i < key . length ; ++ i ) {
110- bytes . push ( key . charCodeAt ( i ) )
111- bytes . push ( 0 )
112- }
113-
114- const b64encoded = window . btoa ( String . fromCharCode . apply ( null , bytes ) )
115- let newIndexValue = ''
116-
117- const propertyBag = allProps . find ( ( el ) => el . key === 'vti_indexedpropertykeys' )
118-
119- // tslint:disable-next-line:prefer-conditional-expression
120- if ( propertyBag && propertyBag . value
121- && propertyBag . value . length > 0 ) {
122- newIndexValue = propertyBag . value . indexOf ( `${ b64encoded } |` ) === - 1 ? `${ propertyBag . value } ${ b64encoded } |` : propertyBag . value
123- } else {
124- newIndexValue = `${ b64encoded } |`
106+ }
107+
108+ const bytes = [ ]
109+ for ( let i = 0 ; i < key . length ; ++ i ) {
110+ bytes . push ( key . charCodeAt ( i ) )
111+ bytes . push ( 0 )
112+ }
113+
114+ const b64encoded = window . btoa ( String . fromCharCode . apply ( null , bytes ) )
115+ let newIndexValue = ''
116+
117+ const propertyBag = allProps . find ( ( el ) => el . key === 'vti_indexedpropertykeys' )
118+
119+ if ( indexed ) {
120+ newIndexValue = propertyBag && propertyBag . value && propertyBag . value . length > 0 ?
121+ propertyBag . value . indexOf ( `${ b64encoded } |` ) === - 1 ? `${ propertyBag . value } ${ b64encoded } |` : propertyBag . value
122+ : newIndexValue = `${ b64encoded } |`
123+ } else {
124+ if ( propertyBag && propertyBag . value && propertyBag . value . length > 0 ) {
125+ newIndexValue = propertyBag . value
126+ newIndexValue = newIndexValue . replace ( b64encoded + '|' , '' )
125127 }
128+ }
126129
127- const payload2 = `
130+ const payload2 = `
128131 <Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="SPEditor">
129132 <Actions>
130133 <Method Name="SetFieldValue" Id="9" ObjectPathId="4">
@@ -141,18 +144,18 @@ export function createWebProperty(...args: any) {
141144 </ObjectPaths>
142145 </Request>`
143146
144- client . post ( endpoint , {
145- headers : {
146- Accept : '*/*' ,
147- 'Content-Type' : 'text/xml;charset="UTF-8"' ,
148- 'X-Requested-With' : 'XMLHttpRequest' ,
149- } ,
150- body : payload2 ,
151- } ) . then ( postMessage )
152- } )
153- } else {
154- postMessage ( )
155- }
147+ client . post ( endpoint , {
148+ headers : {
149+ Accept : '*/*' ,
150+ 'Content-Type' : 'text/xml;charset="UTF-8"' ,
151+ 'X-Requested-With' : 'XMLHttpRequest' ,
152+ } ,
153+ body : payload2 ,
154+ } ) . then ( postMessage )
155+ } )
156+ /* } else {
157+ postMessage()
158+ }*/
156159 } )
157160 } )
158161 } )
0 commit comments