@@ -1805,15 +1805,15 @@ const Fetch = (() => { //eslint-disable-line no-unused-vars
18051805 !fetchprops --type=<type>
18061806 */
18071807 if ( ! ( msg . type === "api" && / ^ ! f e t c h p r o p s / i. test ( msg . content ) ) ) return ;
1808+ if ( / ^ ! f e t c h p r o p s - r e b u i l d / i. test ( msg . content ) ) {
1809+ buildPropContainers ( ) ;
1810+ }
18081811 let contents = [ ] ;
18091812 let rptArgs = {
18101813 type : '' ,
18111814 ref : '' ,
18121815 object : undefined
18131816 } ;
1814- const defaultReport = ( t , contents ) => {
1815- sendChat ( '' , `/w gm &{template:default} {{name=${ t } }} {{ ${ contents . join ( '}} {{ ' ) } }}` , false ) ;
1816- } ;
18171817 const propNicks = ( type ) => {
18181818 let nicks = [ ...Object . entries ( customPropsByType [ type ] ?. compProps || { } ) . map ( e => [ e [ 0 ] , ...e [ 1 ] . nicks ] ) ,
18191819 ...Object . entries ( customPropsByType [ type ] ?. nicks || { } ) . map ( e => [ e [ 0 ] , ...e [ 1 ] ] ) ] ;
@@ -1824,22 +1824,24 @@ const Fetch = (() => { //eslint-disable-line no-unused-vars
18241824 let remainingProps = Object . keys ( propContainers [ type ] || { } ) . filter ( p => ! filterProps . includes ( p ) ) ;
18251825 remainingProps . filter ( k => ! / ^ _ / . test ( k ) ) . forEach ( k => { nicks . push ( [ k ] ) ; } ) ;
18261826 remainingProps . filter ( k => / ^ _ / . test ( k ) ) . forEach ( k => { nicks . find ( n => n . includes ( k . slice ( 1 ) ) ) . unshift ( k ) ; } ) ;
1827- return nicks ;
1827+ return nicks . map ( props => props . sort ( ) ) . sort ( ( a , b ) => a [ 0 ] > b [ 0 ] ? 1 : - 1 ) ;
18281828 }
18291829
18301830 let [ handle , args ] = ( ( apriori = msg . content . split ( / \s + - - / ) ) => { return [ apriori [ 0 ] , apriori . slice ( 1 ) ] ; } ) ( ) ;
18311831
18321832 let typesWithProps = Object . keys ( propContainers || { } ) ;
18331833 let tbl = '' ;
18341834
1835- args . forEach ( a => {
1835+ args . filter ( a => / ^ ( [ ^ # \| = : ] + ) (?: # | \| | = | : ) ( . + ) $ / . test ( a ) ) . forEach ( a => {
18361836 let argParts = a . split ( / ^ ( [ ^ # \| = : ] + ) (?: # | \| | = | : ) ( .+ ) $ / ) . slice ( 1 , 3 ) ;
18371837 if ( argParts [ 0 ] . toLowerCase ( ) === 'type' && typesWithProps . includes ( argParts [ 1 ] . toLowerCase ( ) ) ) {
18381838 rptArgs . type = argParts [ 1 ] . toLowerCase ( ) ;
18391839 } else if ( argParts [ 0 ] . toLowerCase ( ) === 'for' ) {
18401840 rptArgs . ref = argParts [ 1 ] ;
18411841 }
18421842 } ) ;
1843+ let btnRebuild = Messenger . Button ( { type : '!' , label : 'Rebuild' , elem : `!fetchprops-rebuild${ rptArgs . type && rptArgs . type . length ? ' --type=' + rptArgs . type : '' } ` , css : localCSS . button } ) ;
1844+ let tblFooter = html . table ( html . tr ( html . td ( btnRebuild , localCSS . textright ) ) ) ;
18431845 if ( ! args . length || ! rptArgs . type ) { // handle only
18441846 tbl = html . table (
18451847 typesWithProps . filter ( t => propContainers [ t ] ) . sort ( ) . map ( ( k , i ) => html . tr (
@@ -1849,7 +1851,7 @@ const Fetch = (() => { //eslint-disable-line no-unused-vars
18491851 i % 2 === 1 ? localCSS . tblOddRow : { }
18501852 ) ) . join ( '' )
18511853 ) ;
1852- msgbox ( { title : `Fetch Props for Each Type` , whisperto : getWhisperTo ( msg . who ) , msg : tbl , headercss : localCSS . msgheader } ) ;
1854+ msgbox ( { title : `Fetch Props for Each Type` , whisperto : getWhisperTo ( msg . who ) , msg : tbl , headercss : localCSS . msgheader , btn : tblFooter } ) ;
18531855 } else { // handle with type
18541856 let nicks = propNicks ( rptArgs . type ) ;
18551857 tbl = html . table (
@@ -1858,7 +1860,7 @@ const Fetch = (() => { //eslint-disable-line no-unused-vars
18581860 i % 2 === 1 ? localCSS . tblOddRow : { }
18591861 ) ) . join ( '' )
18601862 ) ;
1861- msgbox ( { title : `Fetch Props for ${ rptArgs . type } ` , whisperto : getWhisperTo ( msg . who ) , msg : tbl , headercss : localCSS . msgheader } ) ;
1863+ msgbox ( { title : `Fetch Props for ${ rptArgs . type } ` , whisperto : getWhisperTo ( msg . who ) , msg : tbl , headercss : localCSS . msgheader , btn : tblFooter } ) ;
18621864 /*
18631865 nicks.forEach(props => {
18641866 contents.push(`${props.join('%NEWLINE%')}= `); // ${Messenger.HE(propContainers[rptArgs.type][props[0]](rptArgs.object))}`);
0 commit comments