| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831 |
- /*
- *
- * 2.1.11
- *
- */
- Ext.define("Sch.util.Patch", {
- target : null,
- minVersion : null,
- maxVersion : null,
- reportUrl : null,
- description : null,
- applyFn : null,
- ieOnly : false,
- onClassExtended : function(a, b) {
- if (Sch.disableOverrides) {
- return
- }
- if (b.ieOnly && !Ext.isIE) {
- return
- }
- if ((!b.minVersion || Ext.versions.extjs.equals(b.minVersion) || Ext.versions.extjs
- .isGreaterThan(b.minVersion))
- && (!b.maxVersion || Ext.versions.extjs.equals(b.maxVersion) || Ext.versions.extjs
- .isLessThan(b.maxVersion))) {
- if (b.applyFn) {
- b.applyFn()
- } else {
- b.requires[0].override(b.overrides)
- }
- }
- }
- });
- Ext.define("Sch.patches.LoadMask", {
- extend : "Sch.util.Patch",
- requires : ["Ext.view.AbstractView"],
- minVersion : "4.1.0b3",
- reportURL : "http://www.sencha.com/forum/showthread.php?187700-4.1.0-B3-Ext.AbstractView-no-longer-binds-its-store-to-load-mask",
- description : "In Ext4.1 loadmask no longer bind the store",
- overrides : {}
- });
- Ext.define("Sch.patches.Table", {
- extend : "Sch.util.Patch",
- requires : ["Ext.view.Table"],
- minVersion : "4.1.1",
- maxVersion : "4.1.1",
- reportURL : "http://www.sencha.com/forum/showthread.php?238026-4.1.1-Alt-row-styling-lost-after-record-update&p=874190#post874190",
- description : "In Ext4.1.1 when record is updated, the alternate row styling is lost",
- overrides : {
- onUpdate : function(c, a, b, e) {
- var d = this.store.indexOf(a);
- this.callParent(arguments);
- this.doStripeRows(d, d)
- }
- }
- });
- Ext.define("Sch.patches.TreeView", {
- extend : "Sch.util.Patch",
- requires : ["Ext.tree.View"],
- maxVersion : "4.1.3",
- applyFn : function() {
- Ext.tree.View.addMembers({
- providedStore : null,
- initComponent : function() {
- var a = this, b = a.panel.getStore();
- if (a.initialConfig.animate === undefined) {
- a.animate = Ext.enableFx
- }
- a.store = a.providedStore
- || new Ext.data.NodeStore({
- treeStore : b,
- recursive : true,
- rootVisible : a.rootVisible
- });
- a.store.on({
- beforeexpand : a.onBeforeExpand,
- expand : a.onExpand,
- beforecollapse : a.onBeforeCollapse,
- collapse : a.onCollapse,
- write : a.onStoreWrite,
- datachanged : a.onStoreDataChanged,
- collapsestart : a.beginBulkUpdate,
- collapsecomplete : a.endBulkUpdate,
- scope : a
- });
- if (Ext.versions.extjs
- .isGreaterThanOrEqual("4.1.2")) {
- a.mon(b, {
- scope : a,
- beforefill : a.onBeforeFill,
- fillcomplete : a.onFillComplete,
- beforebulkremove : a.beginBulkUpdate,
- bulkremovecomplete : a.endBulkUpdate
- });
- if (!b.remoteSort) {
- a.mon(b, {
- scope : a,
- beforesort : a.onBeforeSort,
- sort : a.onSort
- })
- }
- }
- if (a.node && !a.store.node) {
- a.setRootNode(a.node)
- }
- a.animQueue = {};
- a.animWraps = {};
- a.addEvents("afteritemexpand",
- "afteritemcollapse");
- a.callParent(arguments);
- a.on({
- element : "el",
- scope : a,
- delegate : a.expanderSelector,
- mouseover : a.onExpanderMouseOver,
- mouseout : a.onExpanderMouseOut
- });
- a.on({
- element : "el",
- scope : a,
- delegate : a.checkboxSelector,
- click : a.onCheckboxChange
- })
- }
- })
- }
- });
- Ext.define("Sch.patches.DataOperation", {
- extend : "Sch.util.Patch",
- requires : ["Ext.data.Operation"],
- reportURL : "http://www.sencha.com/forum/showthread.php?198894-4.1-Ext.data.TreeStore-CRUD-regression.",
- description : "In Ext 4.1.0 newly created records do not get the Id returned by server applied",
- maxVersion : "4.1.0",
- overrides : {
- commitRecords : function(j) {
- var g = this, h, f, a, c, b, d, e;
- if (!g.actionSkipSyncRe.test(g.action)) {
- a = g.records;
- if (a && a.length) {
- if (a.length > 1) {
- if (g.action == "update" || a[0].clientIdProperty) {
- h = new Ext.util.MixedCollection();
- h.addAll(j);
- for (f = a.length; f--;) {
- b = a[f];
- c = h.findBy(g.matchClientRec, b);
- b.copyFrom(c)
- }
- } else {
- for (d = 0, e = a.length; d < e; ++d) {
- b = a[d];
- c = j[d];
- if (b && c) {
- g.updateRecord(b, c)
- }
- }
- }
- } else {
- this.updateRecord(a[0], j[0])
- }
- if (g.actionCommitRecordsRe.test(g.action)) {
- for (f = a.length; f--;) {
- a[f].commit()
- }
- }
- }
- }
- },
- updateRecord : function(a, b) {
- if (b && (a.phantom || a.getId() === b.getId())) {
- a.copyFrom(b)
- }
- }
- }
- });
- Ext.define("Sch.patches.TreeStore", {
- extend : "Sch.util.Patch",
- requires : ["Ext.data.TreeStore"],
- description : "http://www.sencha.com/forum/showthread.php?208602-Model-s-Id-field-not-defined-after-sync-in-TreeStore-%28CRUD%29",
- maxVersion : "4.1.0",
- overrides : {
- onCreateRecords : function(c) {
- this.callParent(arguments);
- var d = 0, b = c.length, a = this.tree, e;
- for (; d < b; ++d) {
- e = c[d];
- a.onNodeIdChanged(e, null, e.getId())
- }
- },
- setRootNode : function(a, e) {
- var d = this, c = d.model, b = c.prototype.idProperty;
- a = a || {};
- if (!a.isModel) {
- Ext.applyIf(a, {
- text : "Root",
- allowDrag : false
- });
- if (a[b] === undefined) {
- a[b] = d.defaultRootId
- }
- Ext.data.NodeInterface.decorate(c);
- a = Ext.ModelManager.create(a, c)
- } else {
- if (a.isModel && !a.isNode) {
- Ext.data.NodeInterface.decorate(c)
- }
- }
- d.getProxy().getReader().buildExtractors(true);
- d.tree.setRootNode(a);
- if (e !== true && !a.isLoaded()
- && (d.autoLoad === true || a.isExpanded())) {
- d.load({
- node : a
- })
- }
- return a
- }
- }
- });
- Ext.define("Sch.util.Date", {
- requires : "Ext.Date",
- singleton : true,
- unitHash : null,
- unitsByName : {},
- unitNames : {
- YEAR : {
- single : "year",
- plural : "years",
- abbrev : "yr"
- },
- QUARTER : {
- single : "quarter",
- plural : "quarters",
- abbrev : "q"
- },
- MONTH : {
- single : "month",
- plural : "months",
- abbrev : "mon"
- },
- WEEK : {
- single : "week",
- plural : "weeks",
- abbrev : "w"
- },
- DAY : {
- single : "day",
- plural : "days",
- abbrev : "d"
- },
- HOUR : {
- single : "hour",
- plural : "hours",
- abbrev : "h"
- },
- MINUTE : {
- single : "minute",
- plural : "minutes",
- abbrev : "min"
- },
- SECOND : {
- single : "second",
- plural : "seconds",
- abbrev : "s"
- },
- MILLI : {
- single : "ms",
- plural : "ms",
- abbrev : "ms"
- }
- },
- constructor : function() {
- var a = Ext.Date;
- var c = this.unitHash = {
- MILLI : a.MILLI,
- SECOND : a.SECOND,
- MINUTE : a.MINUTE,
- HOUR : a.HOUR,
- DAY : a.DAY,
- WEEK : "w",
- MONTH : a.MONTH,
- QUARTER : "q",
- YEAR : a.YEAR
- };
- Ext.apply(this, c);
- var b = this;
- this.units = [b.MILLI, b.SECOND, b.MINUTE, b.HOUR, b.DAY,
- b.WEEK, b.MONTH, b.QUARTER, b.YEAR];
- this.setUnitNames(this.unitNames)
- },
- setUnitNames : function(e) {
- var d = this.unitsByName = {};
- this.unitNames = e;
- var b = this.unitHash;
- for (var a in b) {
- if (b.hasOwnProperty(a)) {
- var c = b[a];
- e[c] = e[a];
- d[a] = c;
- d[c] = c
- }
- }
- },
- betweenLesser : function(b, d, a) {
- var c = b.getTime();
- return d.getTime() <= c && c < a.getTime()
- },
- constrain : function(b, c, a) {
- return this.min(this.max(b, c), a)
- },
- compareUnits : function(c, b) {
- var a = Ext.Array.indexOf(this.units, c), d = Ext.Array
- .indexOf(this.units, b);
- return a > d ? 1 : (a < d ? -1 : 0)
- },
- isUnitGreater : function(b, a) {
- return this.compareUnits(b, a) > 0
- },
- copyTimeValues : function(b, a) {
- b.setHours(a.getHours());
- b.setMinutes(a.getMinutes());
- b.setSeconds(a.getSeconds());
- b.setMilliseconds(a.getMilliseconds())
- },
- add : function(b, c, e) {
- var f = Ext.Date.clone(b);
- if (!c || e === 0) {
- return f
- }
- switch (c.toLowerCase()) {
- case this.MILLI :
- f = new Date(b.getTime() + e);
- break;
- case this.SECOND :
- f = new Date(b.getTime() + (e * 1000));
- break;
- case this.MINUTE :
- f = new Date(b.getTime() + (e * 60000));
- break;
- case this.HOUR :
- f = new Date(b.getTime() + (e * 3600000));
- break;
- case this.DAY :
- f.setDate(b.getDate() + e);
- break;
- case this.WEEK :
- f.setDate(b.getDate() + e * 7);
- break;
- case this.MONTH :
- var a = b.getDate();
- if (a > 28) {
- a = Math.min(a,
- Ext.Date.getLastDateOfMonth(this.add(
- Ext.Date.getFirstDateOfMonth(b),
- this.MONTH, e)).getDate())
- }
- f.setDate(a);
- f.setMonth(f.getMonth() + e);
- break;
- case this.QUARTER :
- f = this.add(b, this.MONTH, e * 3);
- break;
- case this.YEAR :
- f.setFullYear(b.getFullYear() + e);
- break
- }
- return f
- },
- getMeasuringUnit : function(a) {
- if (a === this.WEEK) {
- return this.DAY
- }
- return a
- },
- getDurationInUnit : function(d, a, c) {
- var b;
- switch (c) {
- case this.YEAR :
- b = Math.round(this.getDurationInYears(d, a));
- break;
- case this.QUARTER :
- b = Math.round(this.getDurationInMonths(d, a) / 3);
- break;
- case this.MONTH :
- b = Math.round(this.getDurationInMonths(d, a));
- break;
- case this.WEEK :
- b = Math.round(this.getDurationInDays(d, a)) / 7;
- break;
- case this.DAY :
- b = Math.round(this.getDurationInDays(d, a));
- break;
- case this.HOUR :
- b = Math.round(this.getDurationInHours(d, a));
- break;
- case this.MINUTE :
- b = Math.round(this.getDurationInMinutes(d, a));
- break;
- case this.SECOND :
- b = Math.round(this.getDurationInSeconds(d, a));
- break;
- case this.MILLI :
- b = Math.round(this.getDurationInMilliseconds(d, a));
- break
- }
- return b
- },
- getUnitToBaseUnitRatio : function(b, a) {
- if (b === a) {
- return 1
- }
- switch (b) {
- case this.YEAR :
- switch (a) {
- case this.QUARTER :
- return 1 / 4;
- case this.MONTH :
- return 1 / 12
- }
- break;
- case this.QUARTER :
- switch (a) {
- case this.YEAR :
- return 4;
- case this.MONTH :
- return 1 / 3
- }
- break;
- case this.MONTH :
- switch (a) {
- case this.YEAR :
- return 12;
- case this.QUARTER :
- return 3
- }
- break;
- case this.WEEK :
- switch (a) {
- case this.DAY :
- return 1 / 7;
- case this.HOUR :
- return 1 / 168
- }
- break;
- case this.DAY :
- switch (a) {
- case this.WEEK :
- return 7;
- case this.HOUR :
- return 1 / 24;
- case this.MINUTE :
- return 1 / 1440
- }
- break;
- case this.HOUR :
- switch (a) {
- case this.DAY :
- return 24;
- case this.MINUTE :
- return 1 / 60
- }
- break;
- case this.MINUTE :
- switch (a) {
- case this.HOUR :
- return 60;
- case this.SECOND :
- return 1 / 60;
- case this.MILLI :
- return 1 / 60000
- }
- break;
- case this.SECOND :
- switch (a) {
- case this.MILLI :
- return 1 / 1000
- }
- break;
- case this.MILLI :
- switch (a) {
- case this.SECOND :
- return 1000
- }
- break
- }
- return -1
- },
- getDurationInMilliseconds : function(b, a) {
- return (a - b)
- },
- getDurationInSeconds : function(b, a) {
- return (a - b) / 1000
- },
- getDurationInMinutes : function(b, a) {
- return (a - b) / 60000
- },
- getDurationInHours : function(b, a) {
- return (a - b) / 3600000
- },
- getDurationInDays : function(b, a) {
- return (a - b) / 86400000
- },
- getDurationInBusinessDays : function(g, b) {
- var c = Math.round((b - g) / 86400000), a = 0, f;
- for (var e = 0; e < c; e++) {
- f = this.add(g, this.DAY, e).getDay();
- if (f !== 6 && f !== 0) {
- a++
- }
- }
- return a
- },
- getDurationInMonths : function(b, a) {
- return ((a.getFullYear() - b.getFullYear()) * 12)
- + (a.getMonth() - b.getMonth())
- },
- getDurationInYears : function(b, a) {
- return this.getDurationInMonths(b, a) / 12
- },
- min : function(b, a) {
- return b < a ? b : a
- },
- max : function(b, a) {
- return b > a ? b : a
- },
- intersectSpans : function(c, d, b, a) {
- return this.betweenLesser(c, b, a)
- || this.betweenLesser(b, c, d)
- },
- getNameOfUnit : function(a) {
- a = this.getUnitByName(a);
- switch (a.toLowerCase()) {
- case this.YEAR :
- return "YEAR";
- case this.QUARTER :
- return "QUARTER";
- case this.MONTH :
- return "MONTH";
- case this.WEEK :
- return "WEEK";
- case this.DAY :
- return "DAY";
- case this.HOUR :
- return "HOUR";
- case this.MINUTE :
- return "MINUTE";
- case this.SECOND :
- return "SECOND";
- case this.MILLI :
- return "MILLI"
- }
- throw "Incorrect UnitName"
- },
- getReadableNameOfUnit : function(b, a) {
- return this.unitNames[b][a ? "plural" : "single"]
- },
- getShortNameOfUnit : function(a) {
- return this.unitNames[a].abbrev
- },
- getUnitByName : function(a) {
- if (!this.unitsByName[a]) {
- Ext.Error.raise("Unknown unit name: " + a)
- }
- return this.unitsByName[a]
- },
- getNext : function(c, g, a, f) {
- var e = Ext.Date.clone(c);
- f = arguments.length < 4 ? 1 : f;
- a = a || 1;
- switch (g) {
- case this.MILLI :
- e = this.add(c, g, a);
- break;
- case this.SECOND :
- e = this.add(c, g, a);
- e.setMilliseconds(0);
- break;
- case this.MINUTE :
- e = this.add(c, g, a);
- e.setSeconds(0);
- e.setMilliseconds(0);
- break;
- case this.HOUR :
- e = this.add(c, g, a);
- e.setMinutes(0);
- e.setSeconds(0);
- e.setMilliseconds(0);
- break;
- case this.DAY :
- var d = c.getHours() === 23
- && this.add(e, this.HOUR, 1).getHours() === 1;
- if (d) {
- e = this.add(e, this.DAY, 2);
- Ext.Date.clearTime(e);
- return e
- }
- Ext.Date.clearTime(e);
- e = this.add(e, this.DAY, a);
- break;
- case this.WEEK :
- Ext.Date.clearTime(e);
- var b = e.getDay();
- e = this.add(e, this.DAY, f - b + 7
- * (a - (f <= b ? 0 : 1)));
- if (e.getDay() !== f) {
- e = this.add(e, this.HOUR, 1)
- } else {
- Ext.Date.clearTime(e)
- }
- break;
- case this.MONTH :
- e = this.add(e, this.MONTH, a);
- e.setDate(1);
- Ext.Date.clearTime(e);
- break;
- case this.QUARTER :
- e = this.add(e, this.MONTH, ((a - 1) * 3)
- + (3 - (e.getMonth() % 3)));
- Ext.Date.clearTime(e);
- e.setDate(1);
- break;
- case this.YEAR :
- e = new Date(e.getFullYear() + a, 0, 1);
- break;
- default :
- throw "Invalid date unit"
- }
- return e
- },
- getNumberOfMsFromTheStartOfDay : function(a) {
- return a - Ext.Date.clearTime(a, true) || 86400000
- },
- getNumberOfMsTillTheEndOfDay : function(a) {
- return this.getStartOfNextDay(a, true) - a
- },
- getStartOfNextDay : function(b, e) {
- var d = this.add(Ext.Date.clearTime(b, e), this.DAY, 1);
- if (d.getDate() == b.getDate()) {
- var c = this.add(Ext.Date.clearTime(b, e), this.DAY, 2)
- .getTimezoneOffset();
- var a = b.getTimezoneOffset();
- d = this.add(d, this.MINUTE, a - c)
- }
- return d
- },
- getEndOfPreviousDay : function(b) {
- var a = Ext.Date.clearTime(b, true);
- if (a - b) {
- return a
- } else {
- return this.add(a, this.DAY, -1)
- }
- },
- timeSpanContains : function(c, b, d, a) {
- return (d - c) >= 0 && (b - a) >= 0
- }
- });
- Ext.define("Sch.util.DragTracker", {
- extend : "Ext.dd.DragTracker",
- xStep : 1,
- yStep : 1,
- setXStep : function(a) {
- this.xStep = a
- },
- setYStep : function(a) {
- this.yStep = a
- },
- getRegion : function() {
- var e = this.startXY, d = this.getXY(), b = Math.min(e[0], d[0]), f = Math
- .min(e[1], d[1]), c = Math.abs(e[0] - d[0]), a = Math.abs(e[1]
- - d[1]);
- return new Ext.util.Region(f, b + c, f + a, b)
- },
- onMouseDown : function(f, d) {
- if (this.disabled || f.dragTracked) {
- return
- }
- var c = f.getXY(), g, b, a = c[0], h = c[1];
- if (this.xStep > 1) {
- g = this.el.getX();
- a -= g;
- a = Math.round(a / this.xStep) * this.xStep;
- a += g
- }
- if (this.yStep > 1) {
- b = this.el.getY();
- h -= b;
- h = Math.round(h / this.yStep) * this.yStep;
- h += b
- }
- this.dragTarget = this.delegate ? d : this.handle.dom;
- this.startXY = this.lastXY = [a, h];
- this.startRegion = Ext.fly(this.dragTarget).getRegion();
- if (this.fireEvent("mousedown", this, f) === false
- || this.fireEvent("beforedragstart", this, f) === false
- || this.onBeforeStart(f) === false) {
- return
- }
- this.mouseIsDown = true;
- f.dragTracked = true;
- if (this.preventDefault !== false) {
- f.preventDefault()
- }
- Ext.getDoc().on({
- scope : this,
- mouseup : this.onMouseUp,
- mousemove : this.onMouseMove,
- selectstart : this.stopSelect
- });
- if (this.autoStart) {
- this.timer = Ext.defer(this.triggerStart, this.autoStart === true
- ? 1000
- : this.autoStart, this, [f])
- }
- },
- onMouseMove : function(g, f) {
- if (this.active && Ext.isIE && !g.browserEvent.button) {
- g.preventDefault();
- this.onMouseUp(g);
- return
- }
- g.preventDefault();
- var d = g.getXY(), b = this.startXY;
- if (!this.active) {
- if (Math.max(Math.abs(b[0] - d[0]), Math.abs(b[1] - d[1])) > this.tolerance) {
- this.triggerStart(g)
- } else {
- return
- }
- }
- var a = d[0], h = d[1];
- if (this.xStep > 1) {
- a -= this.startXY[0];
- a = Math.round(a / this.xStep) * this.xStep;
- a += this.startXY[0]
- }
- if (this.yStep > 1) {
- h -= this.startXY[1];
- h = Math.round(h / this.yStep) * this.yStep;
- h += this.startXY[1]
- }
- var c = this.xStep > 1 || this.yStep > 1;
- if (!c || a !== d[0] || h !== d[1]) {
- this.lastXY = [a, h];
- if (this.fireEvent("mousemove", this, g) === false) {
- this.onMouseUp(g)
- } else {
- this.onDrag(g);
- this.fireEvent("drag", this, g)
- }
- }
- }
- });
- Ext.define("Sch.util.HeaderRenderers", {
- singleton : true,
- requires : ["Sch.util.Date", "Ext.XTemplate"],
- constructor : function() {
- var b = Ext
- .create(
- "Ext.XTemplate",
- '<table class="sch-nested-hdr-tbl '
- + Ext.baseCSSPrefix
- + 'column-header-text" cellpadding="0" cellspacing="0"><tr><tpl for="."><td style="width:{[100/xcount]}%" class="{cls} sch-dayheadercell-{dayOfWeek}">{text}</td></tpl></tr></table>')
- .compile();
- var a = Ext
- .create(
- "Ext.XTemplate",
- '<table class="sch-nested-hdr-tbl" cellpadding="0" cellspacing="0"><tr><tpl for="."><td style="width:{[100/xcount]}%" class="{cls}">{text}</td></tpl></tr></table>')
- .compile();
- return {
- quarterMinute : function(f, d, c, e) {
- c.headerCls = "sch-nested-hdr-pad";
- return '<table class="sch-nested-hdr-tbl" cellpadding="0" cellspacing="0"><tr><td>00</td><td>15</td><td>30</td><td>45</td></tr></table>'
- },
- dateCells : function(d, c, e) {
- return function(j, g, f) {
- f.headerCls = "sch-nested-hdr-nopad";
- var i = [], h = Ext.Date.clone(j);
- while (h < g) {
- i.push({
- text : Ext.Date.format(h, e)
- });
- h = Sch.util.Date.add(h, d, c)
- }
- i[0].cls = "sch-nested-hdr-cell-first";
- i[i.length - 1].cls = "sch-nested-hdr-cell-last";
- return a.apply(i)
- }
- },
- dateNumber : function(g, d, c) {
- c.headerCls = "sch-nested-hdr-nopad";
- var f = [], e = Ext.Date.clone(g);
- while (e < d) {
- f.push({
- dayOfWeek : e.getDay(),
- text : e.getDate()
- });
- e = Sch.util.Date.add(e, Sch.util.Date.DAY, 1)
- }
- return b.apply(f)
- },
- dayLetter : function(g, d, c) {
- c.headerCls = "sch-nested-hdr-nopad";
- var f = [], e = g;
- while (e < d) {
- f.push({
- dayOfWeek : e.getDay(),
- text : Ext.Date.dayNames[e.getDay()].substr(0,
- 1)
- });
- e = Sch.util.Date.add(e, Sch.util.Date.DAY, 1)
- }
- f[0].cls = "sch-nested-hdr-cell-first";
- f[f.length - 1].cls = "sch-nested-hdr-cell-last";
- return b.apply(f)
- },
- dayStartEndHours : function(e, d, c) {
- c.headerCls = "sch-hdr-startend";
- return Ext.String
- .format(
- '<span class="sch-hdr-start">{0}</span><span class="sch-hdr-end">{1}</span>',
- Ext.Date.format(e, "G"), Ext.Date
- .format(d, "G"))
- }
- }
- }
- });
- Ext.define("Sch.model.Customizable", {
- extend : "Ext.data.Model",
- customizableFields : null,
- onClassExtended : function(b, d, a) {
- var c = a.onBeforeCreated;
- a.onBeforeCreated = function(f, k) {
- c.call(this, f, k);
- var j = f.prototype;
- if (!j.customizableFields) {
- return
- }
- j.customizableFields = (f.superclass.customizableFields || [])
- .concat(j.customizableFields);
- var g = j.customizableFields;
- var i = {};
- Ext.Array.each(g, function(l) {
- if (typeof l == "string") {
- l = {
- name : l
- }
- }
- i[l.name] = l
- });
- var e = j.fields;
- var h = [];
- e.each(function(l) {
- if (l.isCustomizableField) {
- h.push(l)
- }
- });
- e.removeAll(h);
- Ext.Object.each(i, function(l, o) {
- o.isCustomizableField = true;
- var p = o.name;
- var t = p === "Id" ? "idProperty" : p.charAt(0).toLowerCase()
- + p.substr(1) + "Field";
- var q = j[t];
- var s = q || p;
- if (e.containsKey(s)) {
- e.getByKey(s).isCustomizableField = true;
- g.push(new Ext.data.Field(Ext.applyIf({
- name : p,
- isCustomizableField : true
- }, e.getByKey(s))))
- } else {
- e.add(new Ext.data.Field(Ext.applyIf({
- name : s,
- isCustomizableField : true
- }, o)))
- }
- var n = Ext.String.capitalize(p);
- if (n != "Id") {
- var r = "get" + n;
- var m = "set" + n;
- if (!j[r] || j[r].__getterFor__ && j[r].__getterFor__ != s) {
- j[r] = function() {
- return this.data[s]
- };
- j[r].__getterFor__ = s
- }
- if (!j[m] || j[m].__setterFor__ && j[m].__setterFor__ != s) {
- j[m] = function(u) {
- return this.set(s, u)
- };
- j[m].__setterFor__ = s
- }
- }
- })
- }
- },
- set : function(c, b) {
- if (arguments.length === 2) {
- this.previous = this.previous || {};
- var a = this.get(c);
- if (a !== b) {
- this.previous[c] = a
- }
- }
- this.callParent(arguments)
- },
- afterEdit : function() {
- this.callParent(arguments);
- delete this.previous
- },
- reject : function() {
- var b = this, a = b.modified, c;
- b.previous = b.previous || {};
- for (c in a) {
- if (a.hasOwnProperty(c)) {
- if (typeof a[c] != "function") {
- b.previous[c] = b.get(c)
- }
- }
- }
- b.callParent(arguments);
- delete b.previous
- }
- });
- Ext.define("Sch.patches.Model", {
- extend : "Sch.util.Patch",
- requires : "Sch.model.Customizable",
- reportURL : "http://www.sencha.com/forum/showthread.php?198250-4.1-Ext.data.Model-regression",
- description : "In Ext 4.1 Models cannot be subclassed",
- maxVersion : "4.1.0",
- applyFn : function() {
- try {
- Ext.define("Sch.foo", {
- extend : "Ext.data.Model",
- fields : ["a"]
- });
- Ext.define("Sch.foo.Sub", {
- extend : "Sch.foo",
- fields : ["a"]
- })
- } catch (a) {
- Ext.data.Types.AUTO.convert = function(b) {
- return b
- }
- }
- }
- });
- Ext.define("Sch.data.mixin.EventStore", {
- model : "Sch.model.Event",
- requires : ["Sch.util.Date"],
- isEventStore : true,
- setResourceStore : function(a) {
- if (this.resourceStore) {
- this.resourceStore.un({
- beforesync : this.onResourceStoreBeforeSync,
- write : this.onResourceStoreWrite,
- scope : this
- })
- }
- this.resourceStore = a;
- if (a) {
- a.on({
- beforesync : this.onResourceStoreBeforeSync,
- write : this.onResourceStoreWrite,
- scope : this
- })
- }
- },
- onResourceStoreBeforeSync : function(b, c) {
- var a = b.create;
- if (a) {
- for (var e, d = a.length - 1; d >= 0; d--) {
- e = a[d];
- e._phantomId = e.internalId
- }
- }
- },
- onResourceStoreWrite : function(c, b) {
- if (b.wasSuccessful()) {
- var d = this, a = b.getRecords();
- Ext.each(a, function(e) {
- if (e._phantomId && !e.phantom) {
- d.each(function(f) {
- if (f.getResourceId() === e._phantomId) {
- f.assign(e)
- }
- })
- }
- })
- }
- },
- isDateRangeAvailable : function(f, a, b, d) {
- var c = true, e = Sch.util.Date;
- this.each(function(g) {
- if (e
- .intersectSpans(f, a, g.getStartDate(), g
- .getEndDate())
- && d === g.getResource() && (!b || b !== g)) {
- c = false;
- return false
- }
- });
- return c
- },
- getEventsInTimeSpan : function(d, b, a) {
- if (a !== false) {
- var c = Sch.util.Date;
- return this.queryBy(function(g) {
- var f = g.getStartDate(), e = g.getEndDate();
- return f && e && c.intersectSpans(f, e, d, b)
- })
- } else {
- return this.queryBy(function(g) {
- var f = g.getStartDate(), e = g.getEndDate();
- return f && e && (f - d >= 0) && (b - e >= 0)
- })
- }
- },
- getTotalTimeSpan : function() {
- var a = new Date(9999, 0, 1), b = new Date(0), c = Sch.util.Date;
- this.each(function(d) {
- if (d.getStartDate()) {
- a = c.min(d.getStartDate(), a)
- }
- if (d.getEndDate()) {
- b = c.max(d.getEndDate(), b)
- }
- });
- a = a < new Date(9999, 0, 1) ? a : null;
- b = b > new Date(0) ? b : null;
- return {
- start : a || null,
- end : b || a || null
- }
- },
- getEventsForResource : function(e) {
- var c = [], d, f = e.getId() || e.internalId;
- for (var b = 0, a = this.getCount(); b < a; b++) {
- d = this.getAt(b);
- if (d.data[d.resourceIdField] === f) {
- c.push(d)
- }
- }
- return c
- },
- getClosestSuccessor : function(g, e) {
- var c = Infinity, a = g.getEnd(), f, h;
- e = e || this.getRange();
- for (var d = 0, b = e.length; d < b; d++) {
- h = e[d].getStart() - a;
- if (h >= 0 && h < c) {
- f = e[d];
- c = h
- }
- }
- return f
- }
- });
- Ext.define("Sch.model.Range", {
- extend : "Sch.model.Customizable",
- requires : ["Sch.util.Date", "Sch.patches.DataOperation"],
- startDateField : "StartDate",
- endDateField : "EndDate",
- nameField : "Name",
- clsField : "Cls",
- customizableFields : [{
- name : "StartDate",
- type : "date",
- dateFormat : "c"
- }, {
- name : "EndDate",
- type : "date",
- dateFormat : "c"
- }, {
- name : "Cls",
- type : "string"
- }, {
- name : "Name",
- type : "string"
- }],
- setStartDate : function(a, d) {
- var c = this.getEndDate();
- var b = this.getStartDate();
- this.set(this.startDateField, a);
- if (d === true && c && b) {
- this.setEndDate(Sch.util.Date.add(a, Sch.util.Date.MILLI, c - b))
- }
- },
- setEndDate : function(b, d) {
- var a = this.getStartDate();
- var c = this.getEndDate();
- this.set(this.endDateField, b);
- if (d === true && a && c) {
- this.setStartDate(Sch.util.Date.add(b, Sch.util.Date.MILLI,
- -(c - a)))
- }
- },
- setStartEndDate : function(b, a) {
- this.beginEdit();
- this.set(this.startDateField, b);
- this.set(this.endDateField, a);
- this.endEdit()
- },
- getDates : function() {
- var c = [], b = this.getEndDate();
- for (var a = Ext.Date.clearTime(this.getStartDate(), true); a < b; a = Sch.util.Date
- .add(a, Sch.util.Date.DAY, 1)) {
- c.push(a)
- }
- return c
- },
- forEachDate : function(b, a) {
- return Ext.each(this.getDates(), b, a)
- },
- isValid : function() {
- var b = this.callParent(arguments);
- if (b) {
- var c = this.getStartDate(), a = this.getEndDate();
- b = !c || !a || (a - c >= 0)
- }
- return b
- },
- shift : function(b, a) {
- this.setStartEndDate(Sch.util.Date.add(this.getStartDate(), b, a),
- Sch.util.Date.add(this.getEndDate(), b, a))
- }
- });
- Ext.define("Sch.model.Resource", {
- extend : "Sch.model.Customizable",
- idProperty : "Id",
- nameField : "Name",
- customizableFields : ["Id", {
- name : "Name",
- type : "string"
- }],
- getEventStore : function() {
- return this.stores[0] && this.stores[0].eventStore
- || this.parentNode && this.parentNode.getEventStore()
- },
- getEvents : function(d) {
- var c = [], e, f = this.getId() || this.internalId;
- d = d || this.getEventStore();
- for (var b = 0, a = d.getCount(); b < a; b++) {
- e = d.getAt(b);
- if (e.data[e.resourceIdField] === f) {
- c.push(e)
- }
- }
- return c
- }
- });
- Ext.define("Sch.data.mixin.ResourceStore", {});
- Ext.define("Sch.data.FilterableNodeStore", {
- extend : "Ext.data.NodeStore",
- onNodeExpand : function(f, d, c) {
- var b = [];
- for (var e = 0; e < d.length; e++) {
- var a = d[e];
- if (!(a.isHidden && a.isHidden() || a.hidden || a.data.hidden)) {
- b[b.length] = a
- }
- }
- return this.callParent([f, b, c])
- }
- });
- Ext.define("Sch.data.mixin.FilterableTreeStore", {
- requires : ["Sch.data.FilterableNodeStore"],
- nodeStoreClassName : "Sch.data.FilterableNodeStore",
- nodeStore : null,
- isFilteredFlag : false,
- initTreeFiltering : function() {
- if (!this.nodeStore) {
- this.nodeStore = this.createNodeStore(this)
- }
- this.addEvents("filter-set", "filter-clear",
- "nodestore-datachange-start", "nodestore-datachange-end")
- },
- createNodeStore : function(a) {
- return Ext.create(this.nodeStoreClassName, {
- treeStore : a,
- recursive : true,
- rootVisible : this.rootVisible
- })
- },
- clearTreeFilter : function() {
- if (!this.isTreeFiltered()) {
- return
- }
- this.refreshNodeStoreContent();
- this.isFilteredFlag = false;
- this.fireEvent("filter-clear", this)
- },
- refreshNodeStoreContent : function(f) {
- var a = this.getRootNode(), d = [];
- var c = this.rootVisible;
- var b = function(i) {
- if (i.isHidden && i.isHidden() || i.hidden || i.data.hidden) {
- return
- }
- if (c || i != a) {
- d[d.length] = i
- }
- if (!i.data.leaf && i.isExpanded()) {
- var j = i.childNodes, h = j.length;
- for (var g = 0; g < h; g++) {
- b(j[g])
- }
- }
- };
- b(a);
- this.fireEvent("nodestore-datachange-start", this);
- var e = this.nodeStore;
- if (!this.loadDataInNodeStore || !this.loadDataInNodeStore(d)) {
- e.loadRecords(d)
- }
- if (!f) {
- e.fireEvent("clear", e)
- }
- this.fireEvent("nodestore-datachange-end", this)
- },
- getIndexInTotalDataset : function(b) {
- var a = this.getRootNode();
- index = -1;
- var d = this.rootVisible;
- if (!d && b == a) {
- return -1
- }
- var c = function(g) {
- if (g.isHidden && g.isHidden() || g.hidden || g.data.hidden) {
- if (g == b) {
- return false
- }
- }
- if (d || g != a) {
- index++
- }
- if (g == b) {
- return false
- }
- if (!g.data.leaf && g.isExpanded()) {
- var h = g.childNodes, f = h.length;
- for (var e = 0; e < f; e++) {
- if (c(h[e]) === false) {
- return false
- }
- }
- }
- };
- c(a);
- return index
- },
- isTreeFiltered : function() {
- return this.isFilteredFlag
- },
- filterTreeBy : function(s, b) {
- var g;
- if (arguments.length == 1 && Ext.isObject(arguments[0])) {
- b = s.scope;
- g = s.filter
- } else {
- g = s;
- s = {}
- }
- this.fireEvent("nodestore-datachange-start", this);
- s = s || {};
- var j = s.shallow;
- var r = s.checkParents || j;
- var h = s.fullMathchingParents;
- var c = s.onlyParents || h;
- var e = this.rootVisible;
- if (c && r) {
- throw new Error("Can't combine `onlyParents` and `checkParents` options")
- }
- var o = {};
- var m = this.getRootNode(), d = [];
- var a = function(t) {
- var i = t.parentNode;
- while (i && !o[i.internalId]) {
- o[i.internalId] = true;
- i = i.parentNode
- }
- };
- var k = function(v) {
- if (v.isHidden && v.isHidden() || v.hidden || v.data.hidden) {
- return
- }
- var t, w, u, i;
- if (v.data.leaf) {
- if (g.call(b, v, o)) {
- d[d.length] = v;
- a(v)
- }
- } else {
- if (e || v != m) {
- d[d.length] = v
- }
- if (c) {
- t = g.call(b, v);
- w = v.childNodes;
- u = w.length;
- if (t) {
- o[v.internalId] = true;
- a(v);
- if (h) {
- v.cascadeBy(function(x) {
- d[d.length] = x;
- if (!x.data.leaf) {
- o[x.internalId] = true
- }
- });
- return
- }
- }
- for (i = 0; i < u; i++) {
- if (t && w[i].data.leaf) {
- d[d.length] = w[i]
- } else {
- if (!w[i].data.leaf) {
- k(w[i])
- }
- }
- }
- } else {
- if (r) {
- t = g.call(b, v, o);
- if (t) {
- o[v.internalId] = true;
- a(v)
- }
- }
- if (!r || !j || j && (t || v == m && !e)) {
- w = v.childNodes;
- u = w.length;
- for (i = 0; i < u; i++) {
- k(w[i])
- }
- }
- }
- }
- };
- k(m);
- var f = [];
- for (var p = 0, q = d.length; p < q; p++) {
- var l = d[p];
- if (l.data.leaf || o[l.internalId]) {
- f[f.length] = l
- }
- }
- var n = this.nodeStore;
- if (!this.loadDataInNodeStore || !this.loadDataInNodeStore(f)) {
- n.loadRecords(f, false);
- n.fireEvent("clear", n)
- }
- this.isFilteredFlag = true;
- this.fireEvent("nodestore-datachange-end", this);
- this.fireEvent("filter-set", this)
- },
- hideNodesBy : function(b, a) {
- if (this.isFiltered()) {
- throw new Error("Can't hide nodes of the filtered tree store")
- }
- var c = this;
- a = a || this;
- this.getRootNode().cascadeBy(function(d) {
- d.hidden = b.call(a, d, c)
- });
- this.refreshNodeStoreContent()
- },
- showAllNodes : function() {
- this.getRootNode().cascadeBy(function(a) {
- a.hidden = a.data.hidden = false
- });
- this.refreshNodeStoreContent()
- }
- });
- Ext.define("Sch.data.mixin.BufferableTreeStore", {
- viewSize : 50,
- buffered : false,
- rangeStart : null,
- rangeEnd : null,
- initTreeBuffering : function() {
- if (!this.buffered) {
- return
- }
- var b = this;
- var a = {
- append : this.updateBufferedNodeStore,
- insert : this.updateBufferedNodeStore,
- remove : this.updateBufferedNodeStore,
- move : this.updateBufferedNodeStore,
- expand : this.updateBufferedNodeStore,
- collapse : this.updateBufferedNodeStore,
- sort : this.updateBufferedNodeStore,
- scope : this,
- buffer : 1
- };
- this.on(a);
- this.on("root-fill-start", function() {
- b.nodeStore.suspendEvents();
- b.un(a);
- b.nodeStore.setNode()
- });
- this.on("root-fill-end", function() {
- b.nodeStore.resumeEvents();
- b.on(a);
- this.updateBufferedNodeStore()
- })
- },
- updateBufferedNodeStore : function() {
- this.refreshNodeStoreContent(true)
- },
- loadDataInNodeStore : function(a) {
- if (!this.buffered) {
- return false
- }
- var b = this.nodeStore;
- b.totalCount = a.length;
- if (!a.length) {
- b.removeAll()
- }
- b.cachePage(a, 1);
- this.guaranteeRange(this.rangeStart || 0, this.rangeEnd
- || this.viewSize || 50);
- return true
- },
- guaranteeRange : function(e, d) {
- var b = this.viewSize || 50;
- var f = this.nodeStore;
- var a = f.getTotalCount();
- if (a) {
- var c = d - e + 1;
- if (c < b && a >= c) {
- d = e + b - 1
- }
- if (d >= a) {
- e = a - (d - e);
- d = a - 1;
- e = Math.max(0, e)
- }
- f.guaranteeRange(e, d)
- }
- },
- createNodeStore : function(a) {
- var b = Ext.create(this.nodeStoreClassName
- || "Ext.data.NodeStore", {
- treeStore : a,
- recursive : true,
- rootVisible : this.rootVisible,
- buffered : a.buffered,
- purgePageCount : 0,
- pageSize : 10000000000
- });
- if (a.buffered) {
- this.mon(b, "guaranteedrange", function(d, e, c) {
- this.rangeStart = e;
- this.rangeEnd = c
- }, this)
- }
- return b
- }
- });
- Ext.define("Sch.data.ResourceStore", {
- extend : "Ext.data.Store",
- model : "Sch.model.Resource",
- mixins : ["Sch.data.mixin.ResourceStore"]
- });
- Ext.define("Sch.data.TimeAxis", {
- extend : "Ext.util.Observable",
- requires : ["Ext.data.JsonStore", "Sch.util.Date"],
- continuous : true,
- autoAdjust : true,
- constructor : function(a) {
- Ext.apply(this, a);
- this.originalContinuous = this.continuous;
- this.addEvents("beforereconfigure", "reconfigure");
- this.tickStore = new Ext.data.JsonStore({
- fields : ["start", "end"]
- });
- this.tickStore.on("datachanged", function() {
- this.fireEvent("reconfigure", this)
- }, this);
- this.callParent(arguments)
- },
- reconfigure : function(a) {
- Ext.apply(this, a);
- var c = this.tickStore, b = this.generateTicks(this.start, this.end,
- this.unit, this.increment || 1, this.mainUnit);
- if (this.fireEvent("beforereconfigure", this, this.start, this.end) !== false) {
- c.suspendEvents(true);
- c.loadData(b);
- if (c.getCount() === 0) {
- Ext.Error
- .raise("Invalid time axis configuration or filter, please check your input data.")
- }
- c.resumeEvents()
- }
- },
- setTimeSpan : function(b, a) {
- this.reconfigure({
- start : b,
- end : a
- })
- },
- filterBy : function(b, a) {
- this.continuous = false;
- a = a || this;
- var c = this.tickStore;
- c.clearFilter(true);
- c.suspendEvents(true);
- c.filter([{
- filterFn : function(e, d) {
- return b.call(a, e.data, d)
- }
- }]);
- if (c.getCount() === 0) {
- Ext.Error
- .raise("Invalid time axis filter - no columns passed through the filter. Please check your filter method.");
- this.clearFilter()
- }
- c.resumeEvents()
- },
- isContinuous : function() {
- return this.continuous && !this.tickStore.isFiltered()
- },
- clearFilter : function() {
- this.continuous = this.originalContinuous;
- this.tickStore.clearFilter()
- },
- generateTicks : function(a, d, g, i) {
- var h = [], f, b = Sch.util.Date, e = 0;
- g = g || this.unit;
- i = i || this.increment;
- if (this.autoAdjust) {
- a = this.floorDate(a || this.getStart(), false);
- d = this.ceilDate(d || b.add(a, this.mainUnit, this.defaultSpan),
- false)
- }
- while (a < d) {
- f = this.getNext(a, g, i);
- if (g === b.HOUR && i > 1 && h.length > 0 && e === 0) {
- var c = h[h.length - 1];
- e = ((c.start.getHours() + i) % 24) - c.end.getHours();
- if (e !== 0) {
- f = b.add(f, b.HOUR, e)
- }
- }
- h.push({
- start : a,
- end : f
- });
- a = f
- }
- return h
- },
- getTickFromDate : function(c) {
- if (this.getStart() > c || this.getEnd() < c) {
- return -1
- }
- var f = this.tickStore.getRange(), e, a, d, b;
- for (d = 0, b = f.length; d < b; d++) {
- a = f[d].data.end;
- if (c <= a) {
- e = f[d].data.start;
- return d + (c > e ? (c - e) / (a - e) : 0)
- }
- }
- return -1
- },
- getDateFromTick : function(d, f) {
- var g = this.tickStore.getCount();
- if (d === g) {
- return this.getEnd()
- }
- var a = Math.floor(d), e = d - a, c = this.getAt(a);
- var b = Sch.util.Date.add(c.start, Sch.util.Date.MILLI, e
- * (c.end - c.start));
- if (f) {
- b = this[f + "Date"](b)
- }
- return b
- },
- getAt : function(a) {
- return this.tickStore.getAt(a).data
- },
- getCount : function() {
- return this.tickStore.getCount()
- },
- getTicks : function() {
- var a = [];
- this.tickStore.each(function(b) {
- a.push(b.data)
- });
- return a
- },
- getStart : function() {
- var a = this.tickStore.first();
- if (a) {
- return Ext.Date.clone(a.data.start)
- }
- return null
- },
- getEnd : function() {
- var a = this.tickStore.last();
- if (a) {
- return Ext.Date.clone(a.data.end)
- }
- return null
- },
- roundDate : function(r) {
- var l = Ext.Date.clone(r), b = this.getStart(), s = this.resolutionIncrement;
- switch (this.resolutionUnit) {
- case Sch.util.Date.MILLI :
- var e = Sch.util.Date.getDurationInMilliseconds(b, l), d = Math
- .round(e / s)
- * s;
- l = Sch.util.Date.add(b, Sch.util.Date.MILLI, d);
- break;
- case Sch.util.Date.SECOND :
- var i = Sch.util.Date.getDurationInSeconds(b, l), q = Math
- .round(i / s)
- * s;
- l = Sch.util.Date.add(b, Sch.util.Date.MILLI, q * 1000);
- break;
- case Sch.util.Date.MINUTE :
- var n = Sch.util.Date.getDurationInMinutes(b, l), a = Math
- .round(n / s)
- * s;
- l = Sch.util.Date.add(b, Sch.util.Date.SECOND, a * 60);
- break;
- case Sch.util.Date.HOUR :
- var m = Sch.util.Date.getDurationInHours(this.getStart(), l), j = Math
- .round(m / s)
- * s;
- l = Sch.util.Date.add(b, Sch.util.Date.MINUTE, j * 60);
- break;
- case Sch.util.Date.DAY :
- var c = Sch.util.Date.getDurationInDays(b, l), f = Math.round(c
- / s)
- * s;
- l = Sch.util.Date.add(b, Sch.util.Date.DAY, f);
- break;
- case Sch.util.Date.WEEK :
- Ext.Date.clearTime(l);
- var o = l.getDay() - this.weekStartDay, t;
- if (o < 0) {
- o = 7 + o
- }
- if (Math.round(o / 7) === 1) {
- t = 7 - o
- } else {
- t = -o
- }
- l = Sch.util.Date.add(l, Sch.util.Date.DAY, t);
- break;
- case Sch.util.Date.MONTH :
- var p = Sch.util.Date.getDurationInMonths(b, l)
- + (l.getDate() / Ext.Date.getDaysInMonth(l)), h = Math
- .round(p / s)
- * s;
- l = Sch.util.Date.add(b, Sch.util.Date.MONTH, h);
- break;
- case Sch.util.Date.QUARTER :
- Ext.Date.clearTime(l);
- l.setDate(1);
- l = Sch.util.Date.add(l, Sch.util.Date.MONTH, 3
- - (l.getMonth() % 3));
- break;
- case Sch.util.Date.YEAR :
- var k = Sch.util.Date.getDurationInYears(b, l), g = Math
- .round(k / s)
- * s;
- l = Sch.util.Date.add(b, Sch.util.Date.YEAR, g);
- break
- }
- return l
- },
- floorDate : function(t, d, v) {
- d = d !== false;
- var n = Ext.Date.clone(t), b = d ? this.getStart() : null, u = this.resolutionIncrement, k;
- if (v) {
- k = v
- } else {
- k = d ? this.resolutionUnit : this.mainUnit
- }
- switch (k) {
- case Sch.util.Date.MILLI :
- if (d) {
- var f = Sch.util.Date.getDurationInMilliseconds(b, n), e = Math
- .floor(f / u)
- * u;
- n = Sch.util.Date.add(b, Sch.util.Date.MILLI, e)
- }
- break;
- case Sch.util.Date.SECOND :
- if (d) {
- var j = Sch.util.Date.getDurationInSeconds(b, n), s = Math
- .floor(j / u)
- * u;
- n = Sch.util.Date.add(b, Sch.util.Date.MILLI, s * 1000)
- } else {
- n.setMilliseconds(0)
- }
- break;
- case Sch.util.Date.MINUTE :
- if (d) {
- var p = Sch.util.Date.getDurationInMinutes(b, n), a = Math
- .floor(p / u)
- * u;
- n = Sch.util.Date.add(b, Sch.util.Date.SECOND, a * 60)
- } else {
- n.setSeconds(0);
- n.setMilliseconds(0)
- }
- break;
- case Sch.util.Date.HOUR :
- if (d) {
- var o = Sch.util.Date
- .getDurationInHours(this.getStart(), n), l = Math
- .floor(o / u)
- * u;
- n = Sch.util.Date.add(b, Sch.util.Date.MINUTE, l * 60)
- } else {
- n.setMinutes(0);
- n.setSeconds(0);
- n.setMilliseconds(0)
- }
- break;
- case Sch.util.Date.DAY :
- if (d) {
- var c = Sch.util.Date.getDurationInDays(b, n), g = Math
- .floor(c / u)
- * u;
- n = Sch.util.Date.add(b, Sch.util.Date.DAY, g)
- } else {
- Ext.Date.clearTime(n)
- }
- break;
- case Sch.util.Date.WEEK :
- var r = n.getDay();
- Ext.Date.clearTime(n);
- if (r !== this.weekStartDay) {
- n = Sch.util.Date.add(n, Sch.util.Date.DAY,
- -(r > this.weekStartDay
- ? (r - this.weekStartDay)
- : (7 - r - this.weekStartDay)))
- }
- break;
- case Sch.util.Date.MONTH :
- if (d) {
- var q = Sch.util.Date.getDurationInMonths(b, n), i = Math
- .floor(q / u)
- * u;
- n = Sch.util.Date.add(b, Sch.util.Date.MONTH, i)
- } else {
- Ext.Date.clearTime(n);
- n.setDate(1)
- }
- break;
- case Sch.util.Date.QUARTER :
- Ext.Date.clearTime(n);
- n.setDate(1);
- n = Sch.util.Date.add(n, Sch.util.Date.MONTH,
- -(n.getMonth() % 3));
- break;
- case Sch.util.Date.YEAR :
- if (d) {
- var m = Sch.util.Date.getDurationInYears(b, n), h = Math
- .floor(m / u)
- * u;
- n = Sch.util.Date.add(b, Sch.util.Date.YEAR, h)
- } else {
- n = new Date(t.getFullYear(), 0, 1)
- }
- break
- }
- return n
- },
- ceilDate : function(c, b, f) {
- var e = Ext.Date.clone(c);
- b = b !== false;
- var a = b ? this.resolutionIncrement : 1, g = false, d;
- if (f) {
- d = f
- } else {
- d = b ? this.resolutionUnit : this.mainUnit
- }
- switch (d) {
- case Sch.util.Date.DAY :
- if (e.getMinutes() > 0 || e.getSeconds() > 0
- || e.getMilliseconds() > 0) {
- g = true
- }
- break;
- case Sch.util.Date.WEEK :
- Ext.Date.clearTime(e);
- if (e.getDay() !== this.weekStartDay) {
- g = true
- }
- break;
- case Sch.util.Date.MONTH :
- Ext.Date.clearTime(e);
- if (e.getDate() !== 1) {
- g = true
- }
- break;
- case Sch.util.Date.QUARTER :
- Ext.Date.clearTime(e);
- if (e.getMonth() % 3 !== 0) {
- g = true
- }
- break;
- case Sch.util.Date.YEAR :
- Ext.Date.clearTime(e);
- if (e.getMonth() !== 0 && e.getDate() !== 1) {
- g = true
- }
- break;
- default :
- break
- }
- if (g) {
- return this.getNext(e, d, a)
- } else {
- return e
- }
- },
- getNext : function(b, c, a) {
- return Sch.util.Date.getNext(b, c, a, this.weekStartDay)
- },
- getResolution : function() {
- return {
- unit : this.resolutionUnit,
- increment : this.resolutionIncrement
- }
- },
- setResolution : function(b, a) {
- this.resolutionUnit = b;
- this.resolutionIncrement = a || 1
- },
- shiftNext : function(a) {
- a = a || this.getShiftIncrement();
- var b = this.getShiftUnit();
- this.setTimeSpan(Sch.util.Date.add(this.getStart(), b, a),
- Sch.util.Date.add(this.getEnd(), b, a))
- },
- shiftPrevious : function(a) {
- a = -(a || this.getShiftIncrement());
- var b = this.getShiftUnit();
- this.setTimeSpan(Sch.util.Date.add(this.getStart(), b, a),
- Sch.util.Date.add(this.getEnd(), b, a))
- },
- getShiftUnit : function() {
- return this.shiftUnit || this.getMainUnit()
- },
- getShiftIncrement : function() {
- return this.shiftIncrement || 1
- },
- getUnit : function() {
- return this.unit
- },
- getIncrement : function() {
- return this.increment
- },
- timeSpanInAxis : function(b, a) {
- if (this.continuous) {
- return Sch.util.Date.intersectSpans(b, a, this.getStart(), this
- .getEnd())
- } else {
- return (b < this.getStart() && a > this.getEnd())
- || this.getTickFromDate(b) !== this.getTickFromDate(a)
- }
- },
- forEachInterval : function(b, a, c) {
- c = c || this;
- if (b === "top" || (b === "middle" && this.headerConfig.bottom)) {
- this.forEachAuxInterval(b, a, c)
- } else {
- this.tickStore.each(function(e, d) {
- return a.call(c, e.data.start, e.data.end, d)
- })
- }
- },
- forEachMainInterval : function(a, b) {
- this.forEachInterval("middle", a, b)
- },
- forEachAuxInterval : function(b, a, f) {
- f = f || this;
- var c = this.getEnd(), g = this.getStart(), e = 0, d;
- while (g < c) {
- d = Sch.util.Date.min(this.getNext(g, this.headerConfig[b].unit,
- this.headerConfig[b].increment || 1), c);
- a.call(f, g, d, e);
- g = d;
- e++
- }
- }
- });
- Ext.define("Sch.preset.Manager", {
- extend : "Ext.util.MixedCollection",
- requires : ["Sch.util.Date", "Sch.util.HeaderRenderers"],
- singleton : true,
- constructor : function() {
- this.callParent(arguments);
- this.registerDefaults()
- },
- registerPreset : function(b, a) {
- if (a) {
- var c = a.headerConfig;
- var d = Sch.util.Date;
- for (var e in c) {
- if (c.hasOwnProperty(e)) {
- if (d[c[e].unit]) {
- c[e].unit = d[c[e].unit.toUpperCase()]
- }
- }
- }
- if (!a.timeColumnWidth) {
- a.timeColumnWidth = 50
- }
- if (a.timeResolution && d[a.timeResolution.unit]) {
- a.timeResolution.unit = d[a.timeResolution.unit
- .toUpperCase()]
- }
- if (a.shiftUnit && d[a.shiftUnit]) {
- a.shiftUnit = d[a.shiftUnit.toUpperCase()]
- }
- }
- if (this.isValidPreset(a)) {
- if (this.containsKey(b)) {
- this.removeAtKey(b)
- }
- this.add(b, a)
- } else {
- throw "Invalid preset, please check your configuration"
- }
- },
- isValidPreset : function(a) {
- var d = Sch.util.Date, b = true, c = Sch.util.Date.units;
- for (var e in a.headerConfig) {
- if (a.headerConfig.hasOwnProperty(e)) {
- b = b
- && Ext.Array.indexOf(c, a.headerConfig[e].unit) >= 0
- }
- }
- if (a.timeResolution) {
- b = b && Ext.Array.indexOf(c, a.timeResolution.unit) >= 0
- }
- if (a.shiftUnit) {
- b = b && Ext.Array.indexOf(c, a.shiftUnit) >= 0
- }
- return b
- },
- getPreset : function(a) {
- return this.get(a)
- },
- deletePreset : function(a) {
- this.removeAtKey(a)
- },
- registerDefaults : function() {
- var b = this, a = this.defaultPresets;
- for (var c in a) {
- b.registerPreset(c, a[c])
- }
- },
- defaultPresets : {
- minuteAndHour : {
- timeColumnWidth : 100,
- rowHeight : 24,
- resourceColumnWidth : 100,
- displayDateFormat : "G:i",
- shiftIncrement : 1,
- shiftUnit : "HOUR",
- defaultSpan : 24,
- timeResolution : {
- unit : "MINUTE",
- increment : 30
- },
- headerConfig : {
- middle : {
- unit : "MINUTE",
- increment : "30",
- dateFormat : "i"
- },
- top : {
- unit : "HOUR",
- dateFormat : "D, GA/m"
- }
- }
- },
- hourAndDay : {
- timeColumnWidth : 60,
- rowHeight : 24,
- resourceColumnWidth : 100,
- displayDateFormat : "G:i",
- shiftIncrement : 1,
- shiftUnit : "DAY",
- defaultSpan : 24,
- timeResolution : {
- unit : "MINUTE",
- increment : 30
- },
- headerConfig : {
- middle : {
- unit : "HOUR",
- dateFormat : "G:i"
- },
- top : {
- unit : "DAY",
- dateFormat : "D d/m"
- }
- }
- },
- dayAndWeek : {
- timeColumnWidth : 100,
- rowHeight : 24,
- resourceColumnWidth : 100,
- displayDateFormat : "Y-m-d G:i",
- shiftUnit : "DAY",
- shiftIncrement : 1,
- defaultSpan : 5,
- timeResolution : {
- unit : "HOUR",
- increment : 1
- },
- headerConfig : {
- middle : {
- unit : "DAY",
- dateFormat : "D d M"
- },
- top : {
- unit : "WEEK",
- dateFormat : "W M Y",
- renderer : function(c, b, a) {
- return Sch.util.Date.getShortNameOfUnit("WEEK")
- + "." + Ext.Date.format(c, "W M Y")
- }
- }
- }
- },
- weekAndDay : {
- timeColumnWidth : 100,
- rowHeight : 24,
- resourceColumnWidth : 100,
- displayDateFormat : "Y-m-d",
- shiftUnit : "WEEK",
- shiftIncrement : 1,
- defaultSpan : 1,
- timeResolution : {
- unit : "DAY",
- increment : 1
- },
- headerConfig : {
- bottom : {
- unit : "DAY",
- increment : 1,
- dateFormat : "d/m"
- },
- middle : {
- unit : "WEEK",
- dateFormat : "D d M",
- align : "left"
- }
- }
- },
- weekAndMonth : {
- timeColumnWidth : 100,
- rowHeight : 24,
- resourceColumnWidth : 100,
- displayDateFormat : "Y-m-d",
- shiftUnit : "WEEK",
- shiftIncrement : 5,
- defaultSpan : 6,
- timeResolution : {
- unit : "DAY",
- increment : 1
- },
- headerConfig : {
- middle : {
- unit : "WEEK",
- renderer : function(c, b, a) {
- a.align = "left";
- return Ext.Date.format(c, "d M")
- }
- },
- top : {
- unit : "MONTH",
- dateFormat : "M Y"
- }
- }
- },
- monthAndYear : {
- timeColumnWidth : 110,
- rowHeight : 24,
- resourceColumnWidth : 100,
- displayDateFormat : "Y-m-d",
- shiftIncrement : 3,
- shiftUnit : "MONTH",
- defaultSpan : 12,
- timeResolution : {
- unit : "DAY",
- increment : 1
- },
- headerConfig : {
- middle : {
- unit : "MONTH",
- dateFormat : "M Y"
- },
- top : {
- unit : "YEAR",
- dateFormat : "Y"
- }
- }
- },
- year : {
- timeColumnWidth : 100,
- rowHeight : 24,
- resourceColumnWidth : 100,
- displayDateFormat : "Y-m-d",
- shiftUnit : "YEAR",
- shiftIncrement : 1,
- defaultSpan : 1,
- timeResolution : {
- unit : "MONTH",
- increment : 1
- },
- headerConfig : {
- bottom : {
- unit : "QUARTER",
- renderer : function(c, b, a) {
- return Ext.String.format(Sch.util.Date
- .getShortNameOfUnit("QUARTER")
- .toUpperCase()
- + "{0}", Math.floor(c
- .getMonth()
- / 3)
- + 1)
- }
- },
- middle : {
- unit : "YEAR",
- dateFormat : "Y"
- }
- }
- },
- weekAndDayLetter : {
- timeColumnWidth : 20,
- rowHeight : 24,
- resourceColumnWidth : 100,
- displayDateFormat : "Y-m-d",
- shiftUnit : "WEEK",
- shiftIncrement : 1,
- defaultSpan : 10,
- timeResolution : {
- unit : "DAY",
- increment : 1
- },
- headerConfig : {
- bottom : {
- unit : "DAY",
- increment : 1,
- renderer : function(a) {
- return Ext.Date.dayNames[a.getDay()].substring(
- 0, 1)
- }
- },
- middle : {
- unit : "WEEK",
- dateFormat : "D d M Y",
- align : "left"
- }
- }
- },
- weekDateAndMonth : {
- timeColumnWidth : 30,
- rowHeight : 24,
- resourceColumnWidth : 100,
- displayDateFormat : "Y-m-d",
- shiftUnit : "WEEK",
- shiftIncrement : 1,
- defaultSpan : 10,
- timeResolution : {
- unit : "DAY",
- increment : 1
- },
- headerConfig : {
- middle : {
- unit : "WEEK",
- dateFormat : "d"
- },
- top : {
- unit : "MONTH",
- dateFormat : "Y F",
- align : "left"
- }
- }
- }
- }
- });
- Ext.define("Sch.feature.AbstractTimeSpan", {
- extend : "Ext.AbstractPlugin",
- lockableScope : "normal",
- schedulerView : null,
- timeAxis : null,
- containerEl : null,
- expandToFitView : false,
- disabled : false,
- cls : null,
- template : null,
- store : null,
- renderElementsBuffered : false,
- renderDelay : 15,
- constructor : function(a) {
- this.uniqueCls = this.uniqueCls || ("sch-timespangroup-" + Ext.id());
- Ext.apply(this, a)
- },
- setDisabled : function(a) {
- if (a) {
- this.removeElements()
- }
- this.disabled = a
- },
- getElements : function() {
- if (this.containerEl) {
- return this.containerEl.select("." + this.uniqueCls)
- }
- return null
- },
- removeElements : function() {
- var a = this.getElements();
- if (a) {
- a.remove()
- }
- },
- init : function(a) {
- this.timeAxis = a.getTimeAxis();
- this.schedulerView = a.getSchedulingView();
- if (!this.store) {
- Ext.Error.raise("Error: You must define a store for this plugin")
- }
- this.schedulerView.on({
- afterrender : this.onAfterRender,
- destroy : this.onDestroy,
- scope : this
- })
- },
- onAfterRender : function(b) {
- var a = this.schedulerView;
- this.containerEl = a.el;
- a.mon(this.store, {
- load : this.renderElements,
- datachanged : this.renderElements,
- clear : this.renderElements,
- add : this.renderElements,
- remove : this.renderElements,
- update : this.refreshSingle,
- scope : this
- });
- if (Ext.data.NodeStore && a.store instanceof Ext.data.NodeStore) {
- if (a.animate) {
- } else {
- a.mon(a.store, {
- expand : this.renderElements,
- collapse : this.renderElements,
- scope : this
- })
- }
- }
- a.on({
- refresh : this.renderElements,
- itemadd : this.renderElements,
- itemremove : this.renderElements,
- itemupdate : this.renderElements,
- groupexpand : this.renderElements,
- groupcollapse : this.renderElements,
- columnwidthchange : this.renderElements,
- resize : this.renderElements,
- scope : this
- });
- a.headerCt.on({
- add : this.renderElements,
- remove : this.renderElements,
- scope : this
- });
- a.ownerCt.up("panel").on({
- viewchange : this.renderElements,
- orientationchange : this.renderElements,
- scope : this
- });
- this.renderElements()
- },
- renderElements : function() {
- if (this.renderElementsBuffered || this.disabled
- || this.schedulerView.headerCt.getColumnCount() === 0) {
- return
- }
- this.renderElementsBuffered = true;
- Ext.Function.defer(this.renderElementsInternal, this.renderDelay, this)
- },
- renderElementsInternal : function() {
- this.renderElementsBuffered = false;
- if (this.disabled || this.schedulerView.isDestroyed
- || this.schedulerView.headerCt.getColumnCount() === 0) {
- return
- }
- this.removeElements();
- Ext.core.DomHelper.insertHtml("afterBegin", this.containerEl.dom, this
- .generateMarkup())
- },
- generateMarkup : function(b) {
- var d = this.timeAxis.getStart(), a = this.timeAxis.getEnd(), c = this
- .getElementData(d, a, null, b);
- return this.template.apply(c)
- },
- getElementData : function(b, a) {
- throw "Abstract method call"
- },
- onDestroy : function() {
- if (this.store.autoDestroy) {
- this.store.destroy()
- }
- },
- refreshSingle : function(c, b) {
- var e = Ext.get(this.uniqueCls + "-" + b.internalId);
- if (e) {
- var g = this.timeAxis.getStart(), a = this.timeAxis.getEnd(), f = this
- .getElementData(g, a, [b])[0], d = b.clsField || "Cls";
- if (f) {
- e.dom.className = this.cls + " " + this.uniqueCls + " "
- + (f[d] || "");
- e.setTop(f.top);
- e.setLeft(f.left);
- e.setSize(f.width, f.height)
- } else {
- Ext.destroy(e)
- }
- } else {
- this.renderElements()
- }
- }
- });
- Ext.define("Sch.plugin.Lines", {
- extend : "Sch.feature.AbstractTimeSpan",
- cls : "sch-timeline",
- showTip : true,
- innerTpl : null,
- init : function(b) {
- this.callParent(arguments);
- var a = this.schedulerView;
- if (Ext.isString(this.innerTpl)) {
- this.innerTpl = new Ext.XTemplate(this.innerTpl)
- }
- var c = this.innerTpl;
- if (!this.template) {
- this.template = new Ext.XTemplate(
- '<tpl for=".">',
- '<div id="'
- + this.uniqueCls
- + '-{id}"'
- + (this.showTip
- ? 'title="{[this.getTipText(values)]}" '
- : "")
- + 'class="'
- + this.cls
- + " "
- + this.uniqueCls
- + ' {Cls}" style="left:{left}px;top:{top}px;height:{height}px;width:{width}px">'
- + (c ? "{[this.renderInner(values)]}" : "")
- + "</div>", "</tpl>", {
- getTipText : function(d) {
- return a.getFormattedDate(d.Date) + " "
- + (d.Text || "")
- },
- renderInner : function(d) {
- return c.apply(d)
- }
- })
- }
- },
- getElementData : function(j, m, c) {
- var n = this.store, h = this.schedulerView, e = c || n.getRange(), g = [], a, b, k;
- for (var f = 0, d = e.length; f < d; f++) {
- a = e[f];
- b = a.get("Date");
- if (b && Sch.util.Date.betweenLesser(b, j, m)) {
- k = h.getTimeSpanRegion(b, null, this.expandToFitView);
- g[g.length] = Ext.apply({
- id : a.internalId,
- left : k.left,
- top : k.top,
- width : 1,
- height : k.bottom - k.top
- }, a.data)
- }
- }
- return g
- }
- });
- Ext.define("Sch.plugin.Zones", {
- extend : "Sch.feature.AbstractTimeSpan",
- innerTpl : null,
- requires : ["Sch.model.Range"],
- cls : "sch-zone",
- init : function(a) {
- if (Ext.isString(this.innerTpl)) {
- this.innerTpl = new Ext.XTemplate(this.innerTpl)
- }
- var b = this.innerTpl;
- if (!this.template) {
- this.template = new Ext.XTemplate(
- '<tpl for="."><div id="'
- + this.uniqueCls
- + '-{id}" class="'
- + this.cls
- + " "
- + this.uniqueCls
- + ' {Cls}" style="left:{left}px;top:{top}px;height:{height}px;width:{width}px;{style}">'
- + (b ? "{[this.renderInner(values)]}" : "")
- + "</div></tpl>", {
- renderInner : function(c) {
- return b.apply(c)
- }
- })
- }
- this.callParent(arguments)
- },
- getElementData : function(k, o, d, p) {
- var q = this.store, j = this.schedulerView, f = d || q.getRange(), h = [], a, n, c, m;
- for (var g = 0, e = f.length; g < e; g++) {
- a = f[g];
- n = a.getStartDate();
- c = a.getEndDate();
- if (n && c && Sch.util.Date.intersectSpans(n, c, k, o)) {
- m = j.getTimeSpanRegion(Sch.util.Date.max(n, k), Sch.util.Date
- .min(c, o), this.expandToFitView);
- var b = m.right - m.left;
- h[h.length] = Ext.apply({
- id : a.internalId,
- left : m.left,
- top : m.top,
- width : p ? 0 : b,
- height : m.bottom - m.top,
- style : p ? ("border-left-width:" + b + "px") : "",
- Cls : a.getCls()
- }, a.data)
- }
- }
- return h
- }
- });
- Ext.define("Sch.plugin.Pan", {
- alias : "plugin.pan",
- extend : "Ext.AbstractPlugin",
- lockableScope : "normal",
- enableVerticalPan : true,
- panel : null,
- constructor : function(a) {
- Ext.apply(this, a)
- },
- init : function(a) {
- this.panel = a.normalGrid || a;
- this.view = a.getSchedulingView();
- this.view.on("afterrender", this.onRender, this)
- },
- onRender : function(a) {
- this.view.el.on("mousedown", this.onMouseDown, this)
- },
- onMouseDown : function(b, a) {
- if (b.getTarget("." + this.view.timeCellCls, 10)
- && !b.getTarget(this.view.eventSelector)) {
- this.mouseX = b.getPageX();
- this.mouseY = b.getPageY();
- Ext.getBody().on("mousemove", this.onMouseMove, this);
- Ext.getDoc().on("mouseup", this.onMouseUp, this);
- if (Ext.isIE || Ext.isGecko) {
- Ext.getBody().on("mouseenter", this.onMouseUp, this)
- }
- b.stopEvent()
- }
- },
- onMouseMove : function(d) {
- d.stopEvent();
- var a = d.getPageX(), f = d.getPageY(), c = a - this.mouseX, b = f
- - this.mouseY;
- this.panel.scrollByDeltaX(-c);
- this.mouseX = a;
- this.mouseY = f;
- if (this.enableVerticalPan) {
- this.panel.scrollByDeltaY(-b)
- }
- },
- onMouseUp : function(a) {
- Ext.getBody().un("mousemove", this.onMouseMove, this);
- Ext.getDoc().un("mouseup", this.onMouseUp, this);
- if (Ext.isIE || Ext.isGecko) {
- Ext.getBody().un("mouseenter", this.onMouseUp, this)
- }
- }
- });
- Ext.define("Sch.view.Locking", {
- extend : "Ext.grid.LockingView",
- scheduleEventRelayRe : /^(schedule|event|beforeevent|afterevent|dragcreate|beforedragcreate|afterdragcreate|beforetooltipshow)/,
- constructor : function(b) {
- this.callParent(arguments);
- var e = this, g = [], a = e.scheduleEventRelayRe, f = b.normal
- .getView(), c = f.events, d;
- for (d in c) {
- if (c.hasOwnProperty(d) && a.test(d)) {
- g.push(d)
- }
- }
- e.relayEvents(f, g)
- },
- getElementFromEventRecord : function(a) {
- return this.normal.getView().getElementFromEventRecord(a)
- },
- onClear : function() {
- this.relayFn("onClear", arguments)
- },
- beginBulkUpdate : function() {
- this.relayFn("beginBulkUpdate", arguments)
- },
- endBulkUpdate : function() {
- this.relayFn("endBulkUpdate", arguments)
- },
- refreshKeepingScroll : function() {
- this.locked.getView().refresh();
- this.normal.getView().refreshKeepingScroll()
- }
- });
- Ext.define("Sch.column.Time", {
- extend : "Ext.grid.column.Column",
- alias : "timecolumn",
- draggable : false,
- groupable : false,
- hideable : false,
- sortable : false,
- fixed : true,
- align : "center",
- tdCls : "sch-timetd",
- menuDisabled : true,
- initComponent : function() {
- this.addEvents("timeheaderdblclick");
- this.enableBubble("timeheaderdblclick");
- this.callParent()
- },
- initRenderData : function() {
- var a = this;
- a.renderData.headerCls = a.renderData.headerCls || a.headerCls;
- return a.callParent(arguments)
- },
- onElDblClick : function(b, a) {
- this.callParent(arguments);
- this.fireEvent("timeheaderdblclick", this, this.startDate,
- this.endDate, b)
- }
- }, function() {
- Sch.column.Time.prototype.renderTpl = Sch.column.Time.prototype.renderTpl
- .replace("column-header-inner",
- "column-header-inner sch-timeheader {headerCls}")
- });
- Ext.define("Sch.column.timeAxis.Horizontal", {
- extend : "Ext.grid.column.Column",
- alias : "widget.timeaxiscolumn",
- requires : ["Ext.Date", "Ext.XTemplate", "Sch.column.Time",
- "Sch.preset.Manager"],
- cls : "sch-timeaxiscolumn",
- timeAxis : null,
- renderTpl : '<div id="{id}-titleEl" class="'
- + Ext.baseCSSPrefix
- + 'column-header-inner"><span id="{id}-textEl" style="display:none" class="'
- + Ext.baseCSSPrefix
- + 'column-header-text"></span><tpl if="topHeaderCells">{topHeaderCells}</tpl><tpl if="middleHeaderCells">{middleHeaderCells}</tpl></div>{%this.renderContainer(out,values)%}',
- headerRowTpl : '<table border="0" cellspacing="0" cellpadding="0" style="{tstyle}" class="sch-header-row sch-header-row-{position}"><thead><tr>{cells}</tr></thead></table>',
- headerCellTpl : '<tpl for="."><td class="sch-column-header x-column-header {headerCls}" style="position : static; text-align: {align}; {style}" tabIndex="0" id="{headerId}" headerPosition="{position}" headerIndex="{index}"><div class="x-column-header-inner">{header}</div></td></tpl>',
- columnConfig : {},
- timeCellRenderer : null,
- timeCellRendererScope : null,
- columnWidth : null,
- previousWidth : null,
- previousHeight : null,
- initComponent : function() {
- if (!(this.headerRowTpl instanceof Ext.Template)) {
- this.headerRowTpl = Ext.create("Ext.XTemplate", this.headerRowTpl)
- }
- if (!(this.headerCellTpl instanceof Ext.Template)) {
- this.headerCellTpl = Ext
- .create("Ext.XTemplate", this.headerCellTpl)
- }
- this.columns = [{}];
- this.addEvents("timeheaderdblclick", "timeaxiscolumnreconfigured");
- this.enableBubble("timeheaderdblclick");
- this.stubForResizer = new Ext.Component({
- isOnLeftEdge : function() {
- return false
- },
- isOnRightEdge : function() {
- return false
- },
- el : {
- dom : {
- style : {}
- }
- }
- });
- this.callParent(arguments);
- this.onTimeAxisReconfigure();
- this
- .mon(this.timeAxis, "reconfigure", this.onTimeAxisReconfigure,
- this)
- },
- getSchedulingView : function() {
- return this.getOwnerHeaderCt().view
- },
- onTimeAxisReconfigure : function() {
- var e = this.timeAxis, d = e.preset.timeColumnWidth, f = this.rendered
- && this.getSchedulingView(), g = e.headerConfig, b = e
- .getStart(), c = e.getEnd(), h = {
- renderer : this.timeColumnRenderer,
- scope : this,
- width : this.rendered ? f.calculateTimeColumnWidth(d) : d
- };
- delete this.previousWidth;
- delete this.previousHeight;
- var j = this.columnConfig = this.createColumns(this.timeAxis, g, h);
- Ext.suspendLayouts();
- this.removeAll();
- if (this.rendered) {
- var a = this.el.child(".x-column-header-inner");
- a.select("table").remove();
- var i = this.initRenderData();
- if (j.top) {
- Ext.core.DomHelper.append(a, i.topHeaderCells)
- }
- if (j.middle) {
- Ext.core.DomHelper.append(a, i.middleHeaderCells)
- }
- if (!j.top && !j.middle) {
- this.addCls("sch-header-single-row")
- } else {
- this.removeCls("sch-header-single-row")
- }
- }
- Ext.resumeLayouts();
- this.add(j.bottom);
- if (this.rendered) {
- if (this.fireEvent("timeaxiscolumnreconfigured", this) !== false) {
- f.refresh()
- }
- }
- },
- beforeRender : function() {
- var a = this.columnConfig;
- if (!a.middle && !a.top) {
- this.addCls("sch-header-single-row")
- }
- this.callParent(arguments)
- },
- timeColumnRenderer : function(i, e, f, l, d, c, k) {
- var a = "";
- if (Ext.isIE) {
- e.style += ";z-index:" + (this.items.getCount() - d)
- }
- if (this.timeCellRenderer) {
- var h = this.timeAxis, b = h.getAt(d), g = b.start, j = b.end;
- a = this.timeCellRenderer.call(this.timeCellRendererScope || this,
- e, f, l, d, c, g, j)
- }
- return a
- },
- initRenderData : function() {
- var a = this.columnConfig;
- var c = a.top ? this.headerRowTpl.apply({
- cells : this.headerCellTpl.apply(a.top),
- position : "top",
- tstyle : "border-top : 0; width : 100px"
- }) : "";
- var b = a.middle ? this.headerRowTpl.apply({
- cells : this.headerCellTpl.apply(a.middle),
- position : "middle",
- tstyle : a.top
- ? "width : 100px"
- : "border-top : 0; width : 100px"
- }) : "";
- return Ext.apply(this.callParent(arguments), {
- topHeaderCells : c,
- middleHeaderCells : b
- })
- },
- defaultRenderer : function(c, b, a) {
- return Ext.Date.format(c, a)
- },
- createColumns : function(f, d, g) {
- if (!f || !d) {
- throw "Invalid parameters passed to createColumns"
- }
- var c = [], a = d.bottom || d.middle, h, e = this;
- f.forEachInterval(d.bottom ? "bottom" : "middle", function(l, j, k) {
- h = {
- align : a.align || "center",
- headerCls : "",
- startDate : l,
- endDate : j
- };
- if (a.renderer) {
- h.header = a.renderer.call(a.scope || e, l, j, h, k)
- } else {
- h.header = e.defaultRenderer(l, j, a.dateFormat)
- }
- c[c.length] = Ext
- .create("Sch.column.Time", Ext.apply(h, g))
- });
- var b = this.createHeaderRows(f, d);
- return {
- bottom : c,
- middle : b.middle,
- top : b.top
- }
- },
- createHeaderRows : function(e, c) {
- var d = {};
- if (c.top) {
- var a;
- if (c.top.cellGenerator) {
- a = c.top.cellGenerator.call(this, e.getStart(), e.getEnd())
- } else {
- a = this.createHeaderRow(e, c.top)
- }
- d.top = this.processHeaderRow(a, "top")
- }
- if (c.bottom) {
- var b;
- if (c.middle.cellGenerator) {
- b = c.middle.cellGenerator.call(this, e.getStart(), e.getEnd())
- } else {
- b = this.createHeaderRow(e, c.middle)
- }
- d.middle = this.processHeaderRow(b, "middle")
- }
- return d
- },
- processHeaderRow : function(c, a) {
- var b = this;
- Ext.each(c, function(d, e) {
- d.index = e;
- d.position = a;
- d.headerId = b.stubForResizer.id
- });
- return c
- },
- createHeaderRow : function(e, k) {
- var n = [], l, a = e.getStart(), c = e.getEnd(), m = c - a, j = [], b = a, d = 0, f, g = k.align
- || "center", h;
- while (b < c) {
- h = Sch.util.Date.min(e.getNext(b, k.unit, k.increment || 1), c);
- l = {
- align : g,
- start : b,
- end : h,
- headerCls : ""
- };
- if (k.renderer) {
- l.header = k.renderer.call(k.scope || this, b, h, l, d)
- } else {
- l.header = this.defaultRenderer(b, h, k.dateFormat, l, d)
- }
- n.push(l);
- b = h;
- d++
- }
- return n
- },
- afterLayout : function() {
- delete this.columnWidth;
- this.callParent(arguments);
- var b = this.getWidth();
- var g = this.getHeight();
- if (b === this.previousWidth && g === this.previousHeight) {
- return
- }
- this.previousWidth = b;
- this.previousHeight = g;
- var i = this.columnConfig;
- var e = this;
- var c = this.el;
- var f = i.top;
- var d = 0;
- var a = 0;
- if (f) {
- c.select(".sch-header-row-top").setWidth(this.lastBox.width);
- c.select(".sch-header-row-top td").each(function(l, m, j) {
- var k = e.getHeaderGroupCellWidth(f[j].start, f[j].end);
- l.setVisibilityMode(Ext.Element.DISPLAY);
- if (k) {
- d += k;
- l.show();
- l.setWidth(k)
- } else {
- l.hide()
- }
- })
- }
- var h = i.middle;
- if (h) {
- c.select(".sch-header-row-middle").setWidth(this.lastBox.width);
- c.select(".sch-header-row-middle td").each(function(l, m, j) {
- var k = e.getHeaderGroupCellWidth(h[j].start, h[j].end);
- l.setVisibilityMode(Ext.Element.DISPLAY);
- if (k) {
- a += k;
- l.show();
- l.setWidth(k)
- } else {
- l.hide()
- }
- })
- }
- },
- getHeaderGroupCellWidth : function(h, b) {
- var e = this.timeAxis.unit, d = this.timeAxis.increment, c, g = Sch.util.Date
- .getMeasuringUnit(e), a = Sch.util.Date.getDurationInUnit(h, b,
- g), f = this.getSchedulingView();
- if (this.timeAxis.isContinuous()) {
- c = a * f.getSingleUnitInPixels(g)
- } else {
- c = f.getXYFromDate(b)[0] - f.getXYFromDate(h)[0]
- }
- return c
- },
- onElDblClick : function(d, f) {
- this.callParent(arguments);
- var e = d.getTarget(".sch-column-header");
- if (e) {
- var a = Ext.fly(e).getAttribute("headerPosition"), b = Ext.fly(e)
- .getAttribute("headerIndex"), c = this.columnConfig[a][b];
- this.fireEvent("timeheaderdblclick", this, c.start, c.end, d)
- }
- },
- getTimeColumnWidth : function() {
- if (this.columnWidth === null) {
- this.columnWidth = this.items.get(0).getWidth()
- }
- return this.columnWidth
- },
- setTimeColumnWidth : function(a) {
- this.suspendEvents();
- this.items.each(function(b) {
- b.setWidth(a)
- });
- this.resumeEvents()
- }
- });
- Ext.define("Sch.column.timeAxis.HorizontalSingle", {
- extend : "Sch.column.Time",
- alias : "widget.singletimeaxiscolumn",
- requires : ["Ext.Date", "Ext.XTemplate", "Sch.preset.Manager"],
- cls : "sch-simple-timeaxis",
- timeAxis : null,
- trackHeaderOver : true,
- compactCellWidthThreshold : 16,
- renderTpl : '<div id="{id}-titleEl" class="'
- + Ext.baseCSSPrefix
- + 'column-header-inner"><span id="{id}-textEl" style="display:none" class="'
- + Ext.baseCSSPrefix
- + 'column-header-text"></span><tpl if="topHeaderCells">{topHeaderCells}</tpl><tpl if="middleHeaderCells">{middleHeaderCells}</tpl><tpl if="bottomHeaderCells">{bottomHeaderCells}</tpl></div>{%this.renderContainer(out,values)%}',
- headerRowTpl : '<table border="0" cellspacing="0" cellpadding="0" style="{tstyle}" class="sch-header-row sch-header-row-{position}"><thead><tr><tpl for="cells"><td class="sch-column-header x-column-header {headerCls}" style="position : static; text-align: {align}; {style}" tabIndex="0" id="{headerId}" headerPosition="{parent.position}" headerIndex="{[xindex-1]}"><div class="sch-simple-timeheader">{header}</div></td></tpl></tr></thead></table>',
- columnConfig : {},
- columnWidth : null,
- nbrTimeColumns : null,
- initComponent : function() {
- this.tdCls += " sch-singletimetd";
- if (!(this.headerRowTpl instanceof Ext.Template)) {
- this.headerRowTpl = Ext.create("Ext.XTemplate", this.headerRowTpl)
- }
- this.addEvents("timeheaderdblclick", "timeaxiscolumnreconfigured");
- this.enableBubble("timeheaderdblclick");
- this.callParent(arguments);
- this.onTimeAxisReconfigure();
- this
- .mon(this.timeAxis, "reconfigure", this.onTimeAxisReconfigure,
- this);
- this.on("resize", this.refreshHeaderSizes, this);
- this.ownHoverCls = this.hoverCls;
- this.hoverCls = ""
- },
- getSchedulingView : function() {
- return this.getOwnerHeaderCt().view
- },
- onTimeAxisReconfigure : function() {
- var h = this.timeAxis, g = h.preset.timeColumnWidth, j = this.rendered
- && this.getSchedulingView(), l = h.headerConfig, c = h
- .getStart(), f = h.getEnd(), d = this.rendered ? j
- .calculateTimeColumnWidth(g) : g;
- var o = this.columnConfig = this.createHeaderRows(l);
- var a = o.bottom || o.middle;
- if (this.rendered) {
- var e;
- var b = this.el.child(".x-column-header-inner");
- var i = b.dom;
- var k = i.style.display;
- var m = i.parentNode;
- i.style.display = "none";
- m.removeChild(i);
- i.innerHTML = "";
- var n = this.initRenderData();
- if (o.top) {
- e = Ext.core.DomHelper.append(b, n.topHeaderCells);
- this.refreshHeaderRow("top", e)
- }
- if (o.middle) {
- e = Ext.core.DomHelper.append(b, n.middleHeaderCells);
- this.refreshHeaderRow("middle", e)
- }
- if (o.bottom) {
- e = Ext.core.DomHelper.append(b, n.bottomHeaderCells);
- this.refreshHeaderRow("bottom", e)
- }
- if (!o.top && !o.middle) {
- this.addCls("sch-header-single-row")
- } else {
- this.removeCls("sch-header-single-row")
- }
- m.appendChild(i);
- i.style.display = k;
- if (d !== this.columnWidth || this.nbrTimeColumns !== a.length) {
- this.nbrTimeColumns = a.length;
- this.setTimeColumnWidth(d)
- }
- if (this.fireEvent("timeaxiscolumnreconfigured", this) !== false) {
- j.refreshKeepingResourceScroll(true)
- }
- } else {
- if (d !== this.columnWidth || this.nbrTimeColumns !== a.length) {
- this.nbrTimeColumns = a.length;
- this.setTimeColumnWidth(d)
- }
- }
- },
- beforeRender : function() {
- var b = this, a = this.columnConfig;
- if (!a.middle && !a.top) {
- b.addCls("sch-header-single-row")
- }
- b.callParent(arguments)
- },
- afterRender : function() {
- var a = this;
- if (this.trackHeaderOver) {
- a.el.on({
- mousemove : a.highlightCell,
- delegate : "div.sch-simple-timeheader",
- scope : a
- });
- a.el.on({
- mouseleave : a.clearHighlight,
- scope : a
- })
- }
- a.callParent(arguments)
- },
- initRenderData : function() {
- var a = this.columnConfig;
- var c = a.top ? this.headerRowTpl.apply({
- cells : a.top,
- position : "top",
- tstyle : "border-top : 0; width : 100px"
- }) : "";
- var b = a.middle ? this.headerRowTpl.apply({
- cells : a.middle,
- position : "middle",
- tstyle : a.top
- ? "width : 100px"
- : "border-top : 0; width : 100px"
- }) : "";
- var d = a.bottom ? this.headerRowTpl.apply({
- cells : a.bottom,
- position : "bottom",
- tstyle : "width : 100px"
- }) : "";
- return Ext.apply(this.callParent(arguments), {
- topHeaderCells : c,
- middleHeaderCells : b,
- bottomHeaderCells : d
- })
- },
- defaultRenderer : function(c, b, a) {
- return Ext.Date.format(c, a)
- },
- createHeaderRows : function(a) {
- var b = {};
- for (var c in a) {
- if (a[c].cellGenerator) {
- b[c] = a[c].cellGenerator.call(this, this.timeAxis.getStart(),
- this.timeAxis.getEnd())
- } else {
- b[c] = this.createHeaderRow(c, a[c])
- }
- }
- return b
- },
- createHeaderRow : function(a, c) {
- var b = [], d = this, f, e = c.align || "center";
- this.timeAxis.forEachInterval(a, function(j, g, h) {
- f = {
- align : e,
- start : j,
- end : g,
- headerCls : ""
- };
- if (c.renderer) {
- f.header = c.renderer.call(c.scope || d, j, g, f, h)
- } else {
- f.header = d.defaultRenderer(j, g, c.dateFormat, f, h)
- }
- if (c.unit === Sch.util.Date.DAY
- && (!c.increment || c.increment === 1)) {
- f.headerCls += " sch-dayheadercell-" + j.getDay()
- }
- b.push(f)
- });
- return b
- },
- afterLayout : function() {
- this.callParent(arguments);
- this.refreshHeaderSizes()
- },
- refreshHeaderSizes : function() {
- var a = this.columnConfig;
- if (a.top) {
- this.refreshHeaderRow("top")
- }
- if (a.middle) {
- this.refreshHeaderRow("middle")
- }
- if (a.bottom) {
- this.refreshHeaderRow("bottom")
- }
- },
- refreshHeaderRow : function(a, b) {
- var e = this.el;
- var f = this.columnConfig[a];
- var d = this;
- var c;
- var g = a === "bottom" || (a === "middle" && !this.columnConfig.bottom);
- b = b || e.down(".sch-header-row-" + a, true);
- Ext.fly(b).setWidth(d.getTotalWidth());
- Ext.fly(b).select(" thead > tr > td").each(function(i, j, h) {
- c = g ? d.columnWidth : d.getHeaderGroupCellWidth(f[h].start,
- f[h].end);
- i.setVisibilityMode(Ext.Element.DISPLAY);
- if (c) {
- if (Ext.isSafari && Ext.isMac) {
- c -= 2
- }
- i.show();
- i.setWidth(c - (Ext.chromeVersion === 19 ? (h ? 1 : 0) : 0))
- } else {
- i.hide()
- }
- });
- if (a === "bottom") {
- if (c < this.compactCellWidthThreshold) {
- Ext.fly(b).addCls("sch-header-row-compact")
- } else {
- Ext.fly(b).removeCls("sch-header-row-compact")
- }
- }
- },
- getHeaderGroupCellWidth : function(c, a) {
- var b = this.getSchedulingView();
- return b.getXYFromDate(a)[0] - b.getXYFromDate(c)[0]
- },
- onElDblClick : function(d, f) {
- var e = d.getTarget(".sch-column-header");
- if (e) {
- var a = Ext.fly(e).getAttribute("headerPosition"), b = Ext.fly(e)
- .getAttribute("headerIndex"), c = this.columnConfig[a][b];
- this.fireEvent("timeheaderdblclick", this, c.start, c.end, d)
- }
- },
- getTimeColumnWidth : function() {
- if (this.columnWidth === null) {
- this.columnWidth = this.getWidth() / this.nbrTimeColumns
- }
- return this.columnWidth
- },
- setTimeColumnWidth : function(a) {
- this.columnWidth = a;
- if (this.rendered) {
- Ext.suspendLayouts();
- this.setWidth(a * this.nbrTimeColumns);
- Ext.resumeLayouts();
- this.refreshHeaderSizes();
- this.ownerCt.updateLayout()
- } else {
- this.setWidth(a * this.nbrTimeColumns)
- }
- },
- getTotalWidth : function() {
- return this.columnWidth * this.nbrTimeColumns
- },
- highlightCell : function(c, a) {
- var b = this;
- if (a !== b.highlightedCell) {
- b.clearHighlight();
- b.highlightedCell = a;
- Ext.fly(a).addCls(b.ownHoverCls)
- }
- },
- clearHighlight : function() {
- var b = this, a = b.highlightedCell;
- if (a) {
- Ext.fly(a).removeCls(b.ownHoverCls);
- delete b.highlightedCell
- }
- }
- });
- Ext.define("Sch.mixin.Lockable", {
- extend : "Ext.grid.Lockable",
- requires : ["Sch.column.timeAxis.Horizontal",
- "Sch.column.timeAxis.HorizontalSingle"],
- findEditingPlugin : function() {
- var b = this.plugins || [];
- var c = this;
- var a;
- Ext.each(b, function(e, d) {
- if (Ext.grid.plugin && Ext.grid.plugin.CellEditing
- && e instanceof Ext.grid.plugin.CellEditing) {
- a = e;
- Ext.Array.remove(b, e);
- return false
- }
- });
- return a
- },
- processSchedulerPlugins : function() {
- var e = [];
- var d = [];
- var g = [];
- var a = this.plugins || [];
- var c = this;
- for (var b = a.length - 1; b >= 0; b--) {
- var f = a[b];
- if (f.lockableScope) {
- switch (f.lockableScope) {
- case "top" :
- g.push(f);
- break;
- case "locked" :
- e.push(f);
- break;
- case "normal" :
- d.push(f);
- break
- }
- Ext.Array.remove(a, f)
- }
- }
- if (e.length > 0) {
- c.lockedGridConfig.plugins = (c.lockedGridConfig.plugins || [])
- .concat(e)
- }
- if (d.length > 0) {
- c.normalGridConfig.plugins = (c.normalGridConfig.plugins || [])
- .concat(d)
- }
- c.topPlugins = g
- },
- injectLockable : function() {
- var d = this.findEditingPlugin();
- var k = this;
- var g = Ext.data.TreeStore && k.store instanceof Ext.data.TreeStore;
- var m = k.store.buffered;
- var c = k.getEventSelectionModel ? k.getEventSelectionModel() : k
- .getSelectionModel();
- k.lockedGridConfig = Ext.apply({}, k.lockedGridConfig || {});
- k.normalGridConfig = Ext.apply({}, k.schedulerConfig
- || k.normalGridConfig || {});
- var a = k.lockedGridConfig, j = k.normalGridConfig;
- Ext.applyIf(k.lockedGridConfig, {
- xtype : k.lockedXType,
- id : k.id + "_locked",
- enableLocking : false,
- lockable : false,
- useArrows : true,
- columnLines : k.columnLines,
- rowLines : k.rowLines,
- stateful : k.stateful,
- delayScroll : function() {
- if (this.rendered) {
- return this.self.prototype.delayScroll.apply(this,
- arguments)
- }
- },
- split : true,
- animCollapse : false,
- collapseDirection : "left",
- region : "west"
- });
- if (d) {
- k.lockedGridConfig.plugins = (k.lockedGridConfig.plugins || [])
- .concat(d)
- }
- k.processSchedulerPlugins();
- Ext.applyIf(k.normalGridConfig, {
- xtype : k.normalXType,
- enableLocking : false,
- lockable : false,
- viewType : k.viewType,
- layout : "fit",
- sortableColumns : false,
- enableColumnMove : false,
- enableColumnResize : false,
- enableColumnHide : false,
- selModel : c,
- eventSelModel : c,
- _top : k,
- orientation : k.orientation,
- viewPreset : k.viewPreset,
- timeAxis : k.timeAxis,
- columnLines : k.columnLines,
- rowLines : k.rowLines,
- collapseDirection : "right",
- animCollapse : false,
- region : "center"
- });
- k.bothCfgCopy = k.bothCfgCopy
- || (Ext.grid.Panel && Ext.grid.Panel.prototype.bothCfgCopy)
- || ["invalidateScrollerOnRefresh", "hideHeaders",
- "enableColumnHide", "enableColumnMove",
- "enableColumnResize", "sortableColumns"];
- if (k.orientation === "vertical") {
- a.store = j.store = k.timeAxis.tickStore;
- k.mon(k.resourceStore, {
- clear : k.refreshResourceColumns,
- datachanged : k.refreshResourceColumns,
- update : k.refreshResourceColumns,
- load : k.refreshResourceColumns,
- scope : k
- })
- }
- if (a.width) {
- k.syncLockedWidth = Ext.emptyFn;
- a.scroll = "horizontal";
- a.scrollerOwner = true
- }
- if (k.resourceStore) {
- j.resourceStore = k.resourceStore
- }
- if (k.eventStore) {
- j.eventStore = k.eventStore
- }
- if (k.dependencyStore) {
- j.dependencyStore = k.dependencyStore
- }
- var e = k.lockedViewConfig = k.lockedViewConfig || {};
- var l = k.normalViewConfig = k.normalViewConfig || {};
- if (g && m && Ext.getScrollbarSize().width === 0) {
- k.lockedGridConfig.scroll = "horizontal"
- }
- if (m) {
- e.preserveScrollOnRefresh = true
- }
- e.enableAnimations = k.normalViewConfig.enableAnimations = false;
- if (g) {
- if (Ext.versions.extjs.isLessThan("4.1.3")) {
- k.normalViewConfig.providedStore = e.providedStore = k.store.nodeStore
- } else {
- k.normalViewConfig.store = e.store = k.store.nodeStore
- }
- k.overrideNodeStore(k.store.nodeStore)
- }
- var f = k.layout;
- this.callParent(arguments);
- if (k.topPlugins) {
- k.plugins = k.topPlugins
- }
- if (a.width) {
- k.lockedGrid.setWidth(a.width);
- k.normalGrid.getView().addCls("sch-timeline-horizontal-scroll");
- k.lockedGrid.getView().addCls("sch-locked-horizontal-scroll")
- } else {
- if (k.normalGrid.collapsed) {
- k.normalGrid.collapsed = false;
- k.normalGrid.view.on("boxready", function() {
- k.normalGrid.collapse()
- }, k, {
- delay : 10
- })
- }
- }
- var n = k.lockedGrid.getView();
- var b = k.normalGrid.getView();
- var h;
- if (m) {
- h = k.normalGrid.verticalScroller;
- n.on("render", this.onLockedViewRender, this);
- this.fixPagingScroller(h);
- if (Ext.getVersion("extjs").isLessThan("4.1.1")) {
- if (Ext.getScrollbarSize().width > 0) {
- n.on({
- scroll : {
- fn : k.onLockedViewScroll,
- element : "el",
- scope : k
- }
- })
- }
- }
- }
- if (Ext.getScrollbarSize().width === 0) {
- n.addCls("sch-ganttpanel-force-locked-scroll")
- }
- if (g) {
- this.setupLockableTree()
- }
- if (!b.deferInitialRefresh) {
- var i = b.onRender;
- b.onRender = function() {
- this.doFirstRefresh = function() {
- };
- i.apply(this, arguments);
- delete this.doFirstRefresh
- }
- }
- if (m) {
- b.el = {
- un : function() {
- }
- };
- h.bindView(b);
- b.un("refresh", h.self.prototype.onViewRefresh, h);
- delete b.el
- }
- k.view.clearListeners();
- n.on({
- refresh : k.updateSpacer,
- scope : k
- });
- if (!Ext.grid.Lockable.prototype.updateSpacer) {
- b.on({
- refresh : k.updateSpacer,
- scope : k
- })
- }
- k.view = Ext.create("Sch.view.Locking", {
- locked : k.lockedGrid,
- normal : k.normalGrid,
- panel : k
- });
- if (k.syncRowHeight) {
- n.on("refresh", this.onLockedViewRefresh, this);
- if (g) {
- k.mon(k.store, {
- beforeload : function() {
- n.un({
- itemadd : k.onViewItemAdd,
- scope : k
- });
- b.un({
- itemadd : k.onViewItemAdd,
- scope : k
- })
- },
- load : function() {
- n.un({
- itemadd : k.onViewItemAdd,
- scope : k
- });
- b.un({
- itemadd : k.onViewItemAdd,
- scope : k
- });
- k.prepareFullRowHeightSync();
- k.syncRowHeights()
- }
- });
- k.normalGrid.on("afteritemexpand", k.afterNormalGridItemExpand,
- k)
- }
- n.on({
- itemadd : k.onViewItemAdd,
- scope : k
- });
- b.on({
- itemadd : k.onViewItemAdd,
- itemupdate : k.onNormalViewItemUpdate,
- groupexpand : k.onNormalViewGroupExpand,
- scope : k
- });
- if (Ext.isIE9 && Ext.isStrict) {
- k.onNormalViewItemUpdate = function(o, p, r) {
- r = r.dom ? r.dom : r;
- if (k.lockedGridDependsOnSchedule) {
- var q = k.lockedGrid.getView();
- q.suspendEvents();
- q.onUpdate(k.lockedGrid.store, o);
- q.resumeEvents()
- }
- var s = k.normalGrid.getView().getNode(p);
- s.style.height = r.style.height;
- k.normalHeights[p] = r.style.height;
- k.syncRowHeights()
- }
- }
- }
- if (f !== "fit") {
- k.layout = f
- }
- k.normalGrid.on({
- collapse : k.onNormalGridCollapse,
- expand : k.onNormalGridExpand,
- scope : k
- });
- k.lockedGrid.on({
- collapse : k.onLockedGridCollapse,
- scope : k
- });
- if (this.lockedGrid.view.store !== this.normalGrid.view.store) {
- Ext.Error
- .raise("Sch.mixin.Lockable setup failed, not sharing store between the two views")
- }
- },
- onLockedGridCollapse : function() {
- if (this.normalGrid.collapsed) {
- this.normalGrid.expand()
- }
- },
- onNormalGridCollapse : function() {
- var a = this;
- if (!a.normalGrid.reExpander) {
- a.normalGrid.reExpander = a.normalGrid.placeholder
- }
- if (!a.lockedGrid.rendered) {
- a.lockedGrid.on("render", a.onNormalGridCollapse, a, {
- delay : 1
- })
- } else {
- a.lastLockedWidth = a.lockedGrid.getWidth();
- a.lockedGrid.setWidth(a.getWidth() - 35);
- if (a.lockedGrid.collapsed) {
- a.lockedGrid.expand()
- }
- a.addCls("sch-normalgrid-collapsed")
- }
- },
- onNormalGridExpand : function() {
- this.removeCls("sch-normalgrid-collapsed");
- this.lockedGrid.setWidth(this.lastLockedWidth)
- },
- fixPagingScroller : function(a) {
- var b = a.onViewRefresh;
- a.onViewRefresh = function() {
- var j = this, l = j.store, i, k = j.view, o = k.el, p = o.dom, r, n, h, q = k.table.dom, m, g;
- if (j.focusOnRefresh) {
- o.focus();
- j.focusOnRefresh = false
- }
- j.disabled = true;
- var f = l.getCount() === l.getTotalCount();
- j.stretcher.setHeight(i = j.getScrollHeight());
- g = p.scrollTop;
- j.isScrollRefresh = (g > 0);
- if (j.scrollProportion !== undefined) {
- j.setTablePosition("absolute");
- j.setTableTop((j.scrollProportion && j.tableStart > 0
- ? (i * j.scrollProportion)
- - (q.offsetHeight * j.scrollProportion)
- : 0)
- + "px")
- } else {
- j.setTablePosition("absolute");
- j.setTableTop((m = (j.tableStart || 0) * j.rowHeight) + "px");
- if (j.scrollOffset) {
- r = k.getNodes();
- n = -o.getOffsetsTo(r[j.commonRecordIndex])[1];
- h = n - j.scrollOffset;
- j.position = (p.scrollTop += h)
- } else {
- if ((m > g) || ((m + q.offsetHeight) < g + p.clientHeight)) {
- if (!(f && !m)) {
- j.lastScrollDirection = -1;
- j.position = p.scrollTop = m
- }
- }
- }
- }
- j.disabled = false
- };
- a.setViewTableStyle = function(f, h, g) {
- if (f.table.dom) {
- f.table.dom.style[h] = g
- }
- f = f.lockingPartner;
- if (f) {
- if (f.table.dom) {
- f.table.dom.style[h] = g
- }
- }
- };
- var d = a.view.lockingPartner;
- if (d) {
- var e = a.onLockRefresh;
- var c = function(f) {
- if (f.table.dom) {
- e.apply(this, arguments)
- }
- };
- d.un("refresh", e, a);
- d.on("refresh", c, a);
- a.onLockRefresh = c
- }
- a.view.un("render", a.onViewRender, a);
- a.onViewRender = function() {
- var g = this, f = g.view.el;
- f.setStyle("position", "relative");
- g.stretcher = f.createChild({
- style : {
- position : "absolute",
- width : "1px",
- height : 0,
- top : 0,
- left : 0
- }
- }, f.dom.firstChild)
- };
- a.view.on("render", a.onViewRender, a);
- if (Ext.getVersion("extjs").isLessThan("4.1.3")) {
- a.scrollTo = function(m, g, p, r) {
- var j = this, l = j.view, q = l.el.dom, n = j.store, k = n
- .getTotalCount(), i, f, h, o;
- m = Math.min(Math.max(m, 0), k - 1);
- i = Math
- .max(
- Math
- .min(
- m
- - ((j.leadingBufferZone + j.trailingBufferZone) / 2),
- k - j.viewSize + 1), 0);
- o = i * j.rowHeight;
- f = i + j.viewSize - 1;
- j.lastScrollDirection = undefined;
- j.disabled = true;
- n.guaranteeRange(i, f, function() {
- h = n.pageMap.getRange(m, m)[0];
- l.table.dom.style.top = o + "px";
- q.scrollTop = o = Math.min(Math.max(0,
- o
- - l.table.getOffsetsTo(l
- .getNode(h))[1]),
- q.scrollHeight - q.clientHeight);
- if (Ext.isIE) {
- q.scrollTop = o
- }
- j.disabled = false;
- if (g) {
- j.grid.selModel.select(h)
- }
- if (p) {
- p.call(r || j, m, h)
- }
- })
- }
- }
- },
- onLockedViewScroll : function() {
- if (this.store.buffered) {
- var a = this.normalGrid.getView().el;
- if (!a || !a.child("table", true)) {
- return
- }
- }
- return this.callParent(arguments)
- },
- onNormalViewScroll : function() {
- if (this.store.buffered) {
- var a = this.lockedGrid.getView().el;
- if (!a || !a.child("table", true)) {
- return
- }
- }
- return this.callParent(arguments)
- },
- setupLockableTree : function() {
- var h = this;
- var i = h.store.buffered;
- var c = h.getView();
- var l = h.lockedGrid.getView();
- var d = h.normalGrid.getView();
- var j = d.store;
- var b = h.store;
- var e = Sch.mixin.FilterableTreeView.prototype;
- l.initTreeFiltering = e.initTreeFiltering;
- l.onFilterChangeStart = e.onFilterChangeStart;
- l.onFilterChangeEnd = e.onFilterChangeEnd;
- l.onFilterCleared = e.onFilterCleared;
- l.onFilterSet = e.onFilterSet;
- l.initTreeFiltering();
- if (i) {
- b.on("nodestore-datachange-end", function() {
- if (d.rendered) {
- h.onNormalViewScroll()
- }
- })
- } else {
- this.mon(b, {
- "root-fill-start" : function() {
- j.suspendEvents()
- },
- "root-fill-end" : function() {
- j.resumeEvents();
- c.refresh()
- }
- })
- }
- this.mon(b, "filter", function(n, m) {
- j.filter.apply(j, m);
- c.refresh()
- });
- this.mon(b, "clearfilter", function(m) {
- j.clearFilter();
- c.refresh()
- });
- var g = h.normalGrid.verticalScroller;
- if (i && g) {
- var a = g.onGuaranteedRange;
- g.onGuaranteedRange = function() {
- a.apply(this, arguments);
- Ext.suspendLayouts();
- c.refresh();
- Ext.resumeLayouts()
- }
- }
- var k = l.onAdd;
- var f = l.onRemove;
- l.onAdd = function() {
- Ext.suspendLayouts();
- k.apply(this, arguments);
- Ext.resumeLayouts()
- };
- l.onRemove = function() {
- Ext.suspendLayouts();
- f.apply(this, arguments);
- Ext.resumeLayouts()
- }
- },
- onNormalViewItemUpdate : function(a, b, d) {
- d = d.dom ? d.dom : d;
- if (this.lockedGridDependsOnSchedule) {
- var c = this.lockedGrid.getView();
- c.suspendEvents();
- c.onUpdate(this.lockedGrid.store, a);
- c.resumeEvents()
- }
- var f = this.normalGrid.getView().getNode(b);
- var e = f.style.height !== d.style.height;
- f.style.height = d.style.height;
- this.normalHeights[b] = d.style.height;
- this.syncRowHeights(e)
- },
- afterNormalGridItemExpand : function(a) {
- var c = this;
- var b = c.getSchedulingView();
- a.cascadeBy(function(f) {
- if (f !== a) {
- var e = b.getNode(f);
- if (e) {
- var d = b.indexOf(e);
- c.normalHeights[d] = e.style.height
- }
- }
- });
- c.syncRowHeights(true)
- },
- onViewItemAdd : function(c, d, b) {
- var e = this.normalGrid.getView();
- var f = this.lockedGrid.getView();
- if (e.getNodes().length !== f.getNodes().length) {
- return
- }
- var a = this.normalHeights;
- Ext.each(c, function(h, g) {
- var i = e.getNode(h);
- if (i) {
- a[i.viewIndex] = i.style.height
- }
- });
- this.syncRowHeights()
- },
- processColumns : function(b) {
- var a = this.callParent(arguments);
- var c = [];
- Ext.each(b, function(d) {
- if (d.position == "right") {
- d.processed = true;
- if (!Ext.isNumber(d.width)) {
- Ext.Error
- .raise('"Right" columns must have a fixed width')
- }
- c.push(d);
- Ext.Array.remove(a.locked.items, d);
- a.lockedWidth -= d.width
- }
- });
- if (this.orientation === "horizontal") {
- a.normal.items = [{
- xtype : this.lightWeight
- ? "singletimeaxiscolumn"
- : "timeaxiscolumn",
- timeAxis : this.timeAxis,
- timeCellRenderer : this.timeCellRenderer,
- timeCellRendererScope : this.timeCellRendererScope,
- trackHeaderOver : this.trackHeaderOver
- }].concat(c)
- } else {
- a.locked.items = [Ext.apply({
- xtype : "verticaltimeaxis",
- width : 100,
- timeAxis : this.timeAxis
- }, this.timeAxisColumnCfg || {})];
- a.lockedWidth = a.locked.items[0].width
- }
- return a
- },
- prepareFullRowHeightSync : function() {
- var g = this, h = g.normalGrid.getView(), j = g.lockedGrid.getView();
- if (!h.rendered || !j.rendered) {
- return
- }
- var a = h.el, d = j.el, f = a.query(h.getItemSelector()), b = d.query(j
- .getItemSelector()), e = f.length, c = 0;
- g.lockedHeights = [];
- g.normalHeights = [];
- if (b.length !== e) {
- return
- }
- for (; c < e; c++) {
- g.normalHeights[c] = f[c].style.height
- }
- },
- onLockedViewRefresh : function() {
- this.prepareFullRowHeightSync();
- this.syncRowHeights()
- },
- onNormalViewRefresh : function() {
- var a = this.lockedGrid.getView();
- if (this.lockedGridDependsOnSchedule) {
- a.un("refresh", this.onLockedViewRefresh, this);
- this.lockedGrid.getView().refresh();
- a.on("refresh", this.onLockedViewRefresh, this)
- }
- this.prepareFullRowHeightSync();
- this.syncRowHeights()
- },
- syncRowHeights : function(b) {
- if (!this.lockedGrid.getView().rendered
- || !this.normalGrid.getView().rendered) {
- return
- }
- var j = this, c = j.lockedHeights, k = j.normalHeights, a = [], h = c.length
- || k.length, f = 0, l, d, e, g;
- if (c.length || k.length) {
- l = j.lockedGrid.getView();
- d = j.normalGrid.getView();
- e = l.el.query(l.getItemSelector());
- g = d.el.query(d.getItemSelector());
- if (g.length !== e.length) {
- return
- }
- for (; f < h; f++) {
- if (e[f] && k[f]) {
- e[f].style.height = k[f]
- }
- }
- j.lockedHeights = [];
- j.normalHeights = []
- }
- if (b !== false) {
- j.updateSpacer()
- }
- },
- getMenuItems : function() {
- if (Ext.versions.extjs.isGreaterThanOrEqual("4.1.2")) {
- return this.callParent(arguments)
- }
- return function() {
- return Ext.grid.header.Container.prototype.getMenuItems.apply(this,
- arguments)
- }
- },
- applyColumnsState : Ext.emptyFn,
- updateSpacer : function() {
- var g = this.lockedGrid.getView();
- var e = this.normalGrid.getView();
- if (g.rendered && e.rendered && g.el.child("table")
- && !this.getSchedulingView().__lightRefresh) {
- var f = this, c = g.el, d = e.el.dom, b = c.dom.id + "-spacer", h = (d.offsetHeight - d.clientHeight)
- + "px";
- f.spacerEl = Ext.getDom(b);
- if (Ext.isIE6 || Ext.isIE7 || (Ext.isIEQuirks && Ext.isIE8)
- && f.spacerEl) {
- Ext.removeNode(f.spacerEl);
- f.spacerEl = null
- }
- if (f.spacerEl) {
- f.spacerEl.style.height = h
- } else {
- var a;
- if (this.store.buffered) {
- a = f.normalGrid.verticalScroller.stretcher.item(0).dom.parentNode === c.dom
- ? f.normalGrid.verticalScroller.stretcher.item(0)
- : f.normalGrid.verticalScroller.stretcher.item(1)
- } else {
- a = c
- }
- Ext.core.DomHelper.append(a, {
- id : b,
- cls : this.store.buffered
- ? "sch-locked-buffered-spacer"
- : "",
- style : "height: " + h
- })
- }
- }
- },
- onLockedViewRender : function() {
- var e = this.normalGrid;
- if (!this.lockedStretcher) {
- var c = this.lockedGrid.getView().el;
- var a = this.lockedStretcher = c.createChild({
- cls : "x-stretcher",
- style : {
- position : "absolute",
- width : "1px",
- height : 0,
- top : 0,
- left : 0
- }
- }, c.dom.firstChild)
- }
- if (!e.rendered) {
- e.getView().on("render", this.onLockedViewRender, this);
- return
- }
- var d = this;
- setTimeout(function() {
- var f = e.getView().el;
- if (f && f.dom) {
- e.getView().el.un("scroll", d.onNormalViewScroll, d);
- e.getView().el.on("scroll", d.onNormalViewScroll, d)
- }
- }, 0);
- var b = e.verticalScroller;
- b.stretcher.addCls("x-stretcher");
- b.stretcher = new Ext.dom.CompositeElement([this.lockedStretcher,
- b.stretcher])
- },
- onNormalViewGroupExpand : function() {
- this.prepareFullRowHeightSync();
- this.syncRowHeights()
- },
- overrideNodeStore : function(c) {
- var a = c.onNodeCollapse;
- var b = c.onNodeExpand;
- c.onNodeCollapse = function() {
- Ext.suspendLayouts();
- a.apply(this, arguments);
- Ext.resumeLayouts()
- };
- c.onNodeExpand = function() {
- Ext.suspendLayouts();
- b.apply(this, arguments);
- Ext.resumeLayouts()
- }
- }
- });
- Ext.define("Sch.plugin.TreeCellEditing", {
- extend : "Ext.grid.plugin.CellEditing",
- init : function(a) {
- this._grid = a;
- this.on("beforeedit", this.checkReadOnly, this);
- this.callParent(arguments)
- },
- checkReadOnly : function() {
- var a = this._grid;
- if (!(a instanceof Sch.panel.TimelineTreePanel)) {
- a = a.up("tablepanel")
- }
- return !a.isReadOnly()
- },
- startEditByClick : function(c, a, h, b, g, d, f) {
- if (f.getTarget(c.expanderSelector)) {
- return
- }
- this.callParent(arguments)
- },
- startEdit : function(a, f) {
- if (!a || !f) {
- return
- }
- var d = this, b = d.getEditor(a, f), e = a.get(f.dataIndex), c = d
- .getEditingContext(a, f);
- a = c.record;
- f = c.column;
- d.completeEdit();
- if (f && !f.getEditor(a)) {
- return false
- }
- if (b) {
- c.originalValue = c.value = e;
- if (d.beforeEdit(c) === false
- || d.fireEvent("beforeedit", c) === false || c.cancel) {
- return false
- }
- d.context = c;
- d.setActiveEditor(b);
- d.setActiveRecord(a);
- d.setActiveColumn(f);
- d.grid.view.focusCell({
- column : c.colIdx,
- row : c.rowIdx
- });
- d.editTask.delay(15, d.showEditor, d, [b, c, c.value])
- } else {
- d.grid.getView().getEl(f).focus((Ext.isWebKit || Ext.isIE)
- ? 10
- : false)
- }
- },
- showEditor : function(b, c, g) {
- var e = this, a = c.record, f = c.column, h = e.grid
- .getSelectionModel(), d = h.getCurrentPosition
- && h.getCurrentPosition();
- e.context = c;
- e.setActiveEditor(b);
- e.setActiveRecord(a);
- e.setActiveColumn(f);
- if (h.selectByPosition
- && (!d || d.column !== c.colIdx || d.row !== c.rowIdx)) {
- h.selectByPosition({
- row : c.rowIdx,
- column : c.colIdx
- })
- }
- b.startEdit(e.getCell(a, f), g, c);
- e.editing = true;
- e.scroll = e.view.el.getScroll()
- },
- getEditingContext : function(e, c) {
- var f = this, a = f.grid, i = a.store, b, d, g = a.getView(), h;
- if (Ext.isNumber(e)) {
- b = e;
- e = i.getAt(b)
- } else {
- if (i instanceof Ext.data.Store) {
- b = i.indexOf(e)
- } else {
- b = g.indexOf(g.getNode(e))
- }
- }
- if (Ext.isNumber(c)) {
- d = c;
- c = a.headerCt.getHeaderAtIndex(d)
- } else {
- d = c.getIndex()
- }
- h = e.get(c.dataIndex);
- return {
- grid : a,
- record : e,
- field : c.dataIndex,
- value : h,
- row : g.getNode(b),
- column : c,
- rowIdx : b,
- colIdx : d
- }
- },
- startEditByPosition : function(a) {
- var f = this, d = f.grid, h = d.getSelectionModel(), b = f.view, e = this.view
- .getNode(a.row), g = d.headerCt.getHeaderAtIndex(a.column), c = b
- .getRecord(e);
- if (h.selectByPosition) {
- h.selectByPosition(a)
- }
- f.startEdit(c, g)
- },
- onEditComplete : function(c, g, b) {
- var f = this, d = f.grid, e = f.getActiveColumn(), h = d
- .getSelectionModel(), a;
- if (e) {
- a = f.context.record;
- f.setActiveEditor(null);
- f.setActiveColumn(null);
- f.setActiveRecord(null);
- if (!f.validateEdit()) {
- return
- }
- if (!f.context.doNotUpdateRecord && !a.isEqual(g, b)) {
- a.set(e.dataIndex, g)
- }
- if (h.setCurrentPosition) {
- h.setCurrentPosition(h.getCurrentPosition())
- }
- d.getView().getEl(e).focus();
- f.context.value = g;
- f.fireEvent("edit", f, f.context)
- }
- },
- onSpecialKey : function(a, f, d) {
- if (!Ext.versions.extjs.equals("4.1.2.381")) {
- return this.callParent(arguments)
- }
- var c = this, b = this.grid, g;
- if (d.getKey() === d.TAB) {
- d.stopEvent();
- if (a) {
- a.onEditorTab(d)
- }
- g = b.getSelectionModel();
- if (g.onEditorTab) {
- return g.onEditorTab(b === c.grid ? c : c.lockingPartner, d)
- }
- }
- }
- });
- Ext.define("Sch.feature.ColumnLines", {
- extend : "Sch.plugin.Lines",
- cls : "sch-column-line",
- showTip : false,
- requires : ["Ext.data.Store"],
- init : function(b) {
- this.timeAxis = b.getTimeAxis();
- this.store = Ext.create("Ext.data.JsonStore", {
- model : Ext.define("Sch.model.TimeLine", {
- extend : "Ext.data.Model",
- fields : ["start", {
- name : "Date",
- convert : function(d, c) {
- return c.data.start
- }
- }]
- }),
- data : b.getOrientation() === "horizontal" ? this
- .getData() : []
- });
- this.callParent(arguments);
- var a = this.schedulerView;
- a.timeAxis.on("reconfigure", this.populate, this)
- },
- populate : function() {
- var a = this.schedulerView;
- var b = a.getOrientation() === "horizontal"
- && a.store.getCount() > 0;
- this.store.removeAll(b);
- if (b) {
- this.store.add(this.getData())
- }
- },
- getElementData : function() {
- var a = this.schedulerView;
- if (a.getOrientation() === "horizontal"
- && a.store.getCount() > 0) {
- return this.callParent(arguments)
- }
- return []
- },
- getData : function() {
- var a = [];
- this.timeAxis.forEachMainInterval(function(d, b, c) {
- if (c > 0) {
- a.push({
- start : d
- })
- }
- });
- a.push({
- start : this.timeAxis.getEnd()
- });
- return a
- }
- });
- Ext.define("Sch.plugin.CurrentTimeLine", {
- extend : "Sch.plugin.Lines",
- tooltipText : "Current time",
- updateInterval : 60000,
- autoUpdate : true,
- expandToFitView : true,
- init : function(c) {
- var b = Ext.create("Ext.data.JsonStore", {
- fields : ["Date", "Cls", "Text"],
- data : [{
- Date : new Date(),
- Cls : "sch-todayLine",
- Text : this.tooltipText
- }]
- });
- var a = b.first();
- if (this.autoUpdate) {
- this.runner = Ext.create("Ext.util.TaskRunner");
- this.runner.start({
- run : function() {
- a.set("Date", new Date())
- },
- interval : this.updateInterval
- })
- }
- c.on("destroy", this.onHostDestroy, this);
- this.store = b;
- this.callParent(arguments)
- },
- onHostDestroy : function() {
- if (this.runner) {
- this.runner.stopAll()
- }
- if (this.store.autoDestroy) {
- this.store.destroy()
- }
- }
- });
- Ext.define("Sch.mixin.TimelineView", {
- requires : ["Sch.column.Time", "Sch.data.TimeAxis"],
- orientation : "horizontal",
- overScheduledEventClass : "sch-event-hover",
- selectedEventCls : "sch-event-selected",
- altColCls : "sch-col-alt",
- timeCellCls : "sch-timetd",
- timeCellSelector : ".sch-timetd",
- ScheduleEventMap : {
- click : "Click",
- mousedown : "MouseDown",
- mouseup : "MouseUp",
- dblclick : "DblClick",
- contextmenu : "ContextMenu",
- keydown : "KeyDown",
- keyup : "KeyUp"
- },
- suppressFitCheck : 0,
- forceFit : false,
- inheritables : function() {
- return {
- cellBorderWidth : 1,
- initComponent : function() {
- this.setOrientation(this.panel._top.orientation
- || this.orientation);
- this.addEvents("beforetooltipshow", "scheduleclick",
- "scheduledblclick", "schedulecontextmenu",
- "columnwidthchange");
- this.enableBubble("columnwidthchange");
- var a = {}, c = Sch.util.Date;
- a[c.DAY] = a[c.WEEK] = a[c.MONTH] = a[c.QUARTER] = a[c.YEAR] = null;
- Ext.applyIf(this, {
- eventPrefix : this.id + "-",
- largeUnits : a
- });
- this.callParent(arguments);
- if (this.orientation === "horizontal") {
- this.getTimeAxisColumn().on("timeaxiscolumnreconfigured",
- this.checkHorizontalFit, this)
- }
- var b = this.panel._top;
- Ext.apply(this, {
- eventRendererScope : b.eventRendererScope,
- eventRenderer : b.eventRenderer,
- eventBorderWidth : b.eventBorderWidth,
- timeAxis : b.timeAxis,
- dndValidatorFn : b.dndValidatorFn || Ext.emptyFn,
- resizeValidatorFn : b.resizeValidatorFn
- || Ext.emptyFn,
- createValidatorFn : b.createValidatorFn
- || Ext.emptyFn,
- tooltipTpl : b.tooltipTpl,
- validatorFnScope : b.validatorFnScope || this,
- snapToIncrement : b.snapToIncrement,
- timeCellRenderer : b.timeCellRenderer,
- timeCellRendererScope : b.timeCellRendererScope,
- readOnly : b.readOnly,
- eventResizeHandles : b.eventResizeHandles,
- enableEventDragDrop : b.enableEventDragDrop,
- enableDragCreation : b.enableDragCreation,
- dragConfig : b.dragConfig,
- dropConfig : b.dropConfig,
- resizeConfig : b.resizeConfig,
- createConfig : b.createConfig,
- tipCfg : b.tipCfg,
- orientation : b.orientation,
- getDateConstraints : b.getDateConstraints
- || Ext.emptyFn
- });
- if (this.emptyText) {
- this.emptyText = '<span class="sch-empty-text">'
- + this.emptyText + "</span>"
- }
- },
- onDestroy : function() {
- if (this.tip) {
- this.tip.destroy()
- }
- this.callParent(arguments)
- },
- afterComponentLayout : function() {
- this.callParent(arguments);
- var b = this.getWidth();
- var a = this.getHeight();
- if (b === this.__prevWidth && a === this.__prevHeight) {
- return
- }
- this.__prevWidth = b;
- this.__prevHeight = a;
- if (!this.lockable && !this.suppressFitCheck) {
- this.checkHorizontalFit()
- }
- },
- beforeRender : function() {
- this.callParent(arguments);
- this.addCls("sch-timelineview");
- if (this.readOnly) {
- this.addCls(this._cmpCls + "-readonly")
- }
- },
- afterRender : function() {
- this.callParent(arguments);
- if (this.overScheduledEventClass) {
- this.mon(this.el, {
- mouseover : this.onMouseOver,
- mouseout : this.onMouseOut,
- delegate : this.eventSelector,
- scope : this
- })
- }
- if (this.tooltipTpl) {
- this.el.on("mousemove", this.setupTooltip, this, {
- single : true
- })
- }
- this.setupTimeCellEvents()
- },
- processUIEvent : function(f) {
- var c = this, a = f.getTarget(this.eventSelector), d = c.ScheduleEventMap, b = f.type, g = false;
- if (a && b in d) {
- this.fireEvent(this.scheduledEventName + b, this, this
- .resolveEventRecord(a), f);
- g = !(this.panel.getSelectionModel() instanceof Ext.selection.RowModel)
- }
- if (!g) {
- this.callParent(arguments)
- }
- },
- refresh : function() {
- this.fixedNodes = 0;
- this.callParent(arguments)
- },
- clearViewEl : function() {
- var c = this, b = c.getTargetEl();
- b.down("table").remove();
- if (this.emptyText) {
- var a = b.down(".sch-empty-text");
- if (a) {
- a.remove()
- }
- }
- },
- onMouseOver : function(b, a) {
- if (a !== this.lastItem) {
- this.lastItem = a;
- Ext.fly(a).addCls(this.overScheduledEventClass);
- this.fireEvent("eventmouseenter", this, this
- .resolveEventRecord(a), b)
- }
- },
- onMouseOut : function(b, a) {
- if (this.lastItem) {
- if (!b.within(this.lastItem, true, true)) {
- Ext.fly(this.lastItem)
- .removeCls(this.overScheduledEventClass);
- this.fireEvent("eventmouseleave", this, this
- .resolveEventRecord(this.lastItem), b);
- delete this.lastItem
- }
- }
- },
- highlightItem : function(b) {
- if (b) {
- var a = this;
- a.clearHighlight();
- a.highlightedItem = b;
- Ext.fly(b).addCls(a.overItemCls)
- }
- },
- shouldUpdateCell : function() {
- return true
- }
- }
- },
- hasRightColumns : function() {
- return this.headerCt.items.getCount() > 1
- },
- checkHorizontalFit : function() {
- if (this.orientation === "horizontal") {
- var a = this.getActualTimeColumnWidth();
- var c = this.getFittingColumnWidth();
- if (this.forceFit) {
- if (c != a) {
- this.fitColumns()
- }
- } else {
- if (this.snapToIncrement) {
- var b = this.calculateTimeColumnWidth(a);
- if (b > 0 && b !== a) {
- this.setColumnWidth(b)
- }
- } else {
- if (a < c) {
- this.fitColumns()
- }
- }
- }
- }
- },
- getTimeAxisColumn : function() {
- return this.headerCt.items.get(0)
- },
- getFirstTimeColumn : function() {
- return this.headerCt.getGridColumns()[0]
- },
- getFormattedDate : function(a) {
- return Ext.Date.format(a, this.getDisplayDateFormat())
- },
- getFormattedEndDate : function(d, a) {
- var b = this.timeAxis, c = b.getResolution().unit;
- if (c in this.largeUnits
- && d.getHours() === 0
- && d.getMinutes() === 0
- && !(d.getYear() === a.getYear()
- && d.getMonth() === a.getMonth() && d.getDate() === a
- .getDate())) {
- d = Sch.util.Date.add(d, Sch.util.Date.DAY, -1)
- }
- return Ext.Date.format(d, this.getDisplayDateFormat())
- },
- getDisplayDateFormat : function() {
- return this.displayDateFormat
- },
- setDisplayDateFormat : function(a) {
- this.displayDateFormat = a
- },
- getSingleUnitInPixels : function(a) {
- return Sch.util.Date.getUnitToBaseUnitRatio(this.timeAxis.getUnit(), a)
- * this.getSingleTickInPixels() / this.timeAxis.getIncrement()
- },
- getSingleTickInPixels : function() {
- throw "Must be implemented by horizontal/vertical"
- },
- scrollEventIntoView : function(f, c, a, j, k) {
- k = k || this;
- var h = this;
- var d = this.panel._top.store;
- var i = function(l) {
- l.scrollIntoView(h.el, true, a);
- if (c) {
- if (typeof c === "boolean") {
- l.highlight()
- } else {
- l.highlight(null, c)
- }
- }
- j && j.call(k)
- };
- var e = Ext.data && Ext.data.TreeStore
- && d instanceof Ext.data.TreeStore && !f.isVisible();
- if (e) {
- f.bubble(function(l) {
- l.expand()
- })
- }
- var b = this.getOuterElementFromEventRecord(f);
- if (b) {
- i(b)
- } else {
- var g = this.panel.verticalScroller;
- if (d.buffered && g) {
- Ext.Function.defer(function() {
- g.scrollTo(d.getIndexInTotalDataset(f), false,
- function() {
- var l = h
- .getOuterElementFromEventRecord(f);
- if (l) {
- i(l)
- }
- })
- }, e ? 10 : 0)
- }
- }
- },
- calculateTimeColumnWidth : function(e) {
- if (!this.panel.rendered) {
- return e
- }
- var h = this.forceFit;
- var b = 0, d = this.timeAxis.getUnit(), k = this.timeAxis.getCount(), g = Number.MAX_VALUE;
- if (this.snapToIncrement) {
- var i = this.timeAxis.getResolution(), j = i.unit, c = i.increment;
- g = Sch.util.Date.getUnitToBaseUnitRatio(d, j) * c
- }
- var f = Sch.util.Date.getMeasuringUnit(d);
- g = Math.min(g, Sch.util.Date.getUnitToBaseUnitRatio(d, f));
- var a = Math.floor(this.getAvailableWidthForSchedule() / k);
- b = (h || e < a) ? a : e;
- if (g > 0 && (!h || g < 1)) {
- b = Math.round(Math.max(1, Math[h ? "floor" : "round"](g * b)) / g)
- }
- return b
- },
- getFittingColumnWidth : function() {
- var a = Math.floor(this.getAvailableWidthForSchedule()
- / this.timeAxis.getCount());
- return this.calculateTimeColumnWidth(a)
- },
- fitColumns : function(b) {
- var a = 0;
- if (this.orientation === "horizontal") {
- a = this.getFittingColumnWidth()
- } else {
- a = Math.floor((this.panel.getWidth()
- - Ext.getScrollbarSize().width - 1)
- / this.headerCt.getColumnCount())
- }
- this.setColumnWidth(a, b)
- },
- getAvailableWidthForSchedule : function() {
- var c = (this.lastBox && this.lastBox.width) || this.getWidth();
- var a = this.headerCt.items.items;
- for (var b = 1; b < a.length; b++) {
- c -= a[b].getWidth()
- }
- return c - Ext.getScrollbarSize().width - 1
- },
- getRightColumnsWidth : function() {
- var c = 0;
- var a = this.headerCt.items.items;
- for (var b = 1; b < a.length; b++) {
- c += a[b].getWidth()
- }
- return c
- },
- fixRightColumnsPositions : function() {
- var a = this.headerCt.items.items;
- var c = a[0].getWidth();
- for (var b = 1; b < a.length; b++) {
- var d = a[b];
- d.el.setLeft(c);
- c += d.getWidth()
- }
- },
- getElementFromEventRecord : function(a) {
- return Ext.get(this.eventPrefix + a.internalId)
- },
- getEventNodeByRecord : function(a) {
- return document.getElementById(this.eventPrefix + a.internalId)
- },
- getOuterElementFromEventRecord : function(a) {
- return Ext.get(this.eventPrefix + a.internalId)
- },
- resolveColumnIndex : function(a) {
- return Math.floor(a / this.getActualTimeColumnWidth())
- },
- getStartEndDatesFromRegion : function(b, a) {
- throw "Must be implemented by horizontal/vertical"
- },
- setupTooltip : function() {
- var b = this, a = Ext.apply({
- renderTo : Ext.getBody(),
- delegate : b.eventSelector,
- target : b.el,
- anchor : "b"
- }, b.tipCfg);
- b.tip = Ext.create("Ext.ToolTip", a);
- b.tip.on({
- beforeshow : function(d) {
- if (!d.triggerElement || !d.triggerElement.id) {
- return false
- }
- var c = this.resolveEventRecord(d.triggerElement);
- if (!c
- || this.fireEvent("beforetooltipshow", this, c) === false) {
- return false
- }
- d.update(this.tooltipTpl.apply(this.getDataForTooltipTpl(c)));
- return true
- },
- scope : this
- })
- },
- getDataForTooltipTpl : function(a) {
- return a.data
- },
- getTimeResolution : function() {
- return this.timeAxis.getResolution()
- },
- setTimeResolution : function(b, a) {
- this.timeAxis.setResolution(b, a);
- if (this.snapToIncrement) {
- this.refreshKeepingScroll()
- }
- },
- getEventIdFromDomNodeId : function(a) {
- return a.substring(this.eventPrefix.length)
- },
- getDateFromDomEvent : function(b, a) {
- return this.getDateFromXY(b.getXY(), a)
- },
- handleScheduleEvent : function(c) {
- var b = c.getTarget("." + this.timeCellCls, 2);
- if (b) {
- var a = this.getDateFromDomEvent(c, "floor");
- this.fireEvent("schedule" + c.type, this, a, this.indexOf(this
- .findItemByChild(b)), c)
- }
- },
- setupTimeCellEvents : function() {
- this.mon(this.el, {
- click : this.handleScheduleEvent,
- dblclick : this.handleScheduleEvent,
- contextmenu : this.handleScheduleEvent,
- scope : this
- }, this)
- },
- getSnapPixelAmount : function() {
- if (this.snapToIncrement) {
- var a = this.timeAxis.getResolution();
- return (a.increment || 1) * this.getSingleUnitInPixels(a.unit)
- } else {
- return 1
- }
- },
- getActualTimeColumnWidth : function() {
- return this.headerCt.items.get(0).getTimeColumnWidth()
- },
- setSnapEnabled : function(a) {
- this.snapToIncrement = a;
- if (a) {
- this.refreshKeepingScroll()
- }
- },
- setReadOnly : function(a) {
- this.readOnly = a;
- this[a ? "addCls" : "removeCls"](this._cmpCls + "-readonly")
- },
- isReadOnly : function() {
- return this.readOnly
- },
- setOrientation : function(a) {
- this.orientation = a;
- Ext.apply(this, Sch.view[Ext.String.capitalize(a)].prototype.props)
- },
- getOrientation : function() {
- return this.orientation
- },
- translateToScheduleCoordinate : function(a) {
- throw "Abstract method call!"
- },
- translateToPageCoordinate : function(a) {
- throw "Abstract method call!"
- },
- getDateFromXY : function(c, b, a) {
- throw "Abstract method call!"
- },
- getXYFromDate : function(a, b) {
- throw "Abstract method call!"
- },
- getTimeSpanRegion : function(a, b) {
- throw "Abstract method call!"
- },
- getStart : function() {
- return this.timeAxis.getStart()
- },
- getEnd : function() {
- return this.timeAxis.getEnd()
- },
- setBarMargin : function(b, a) {
- this.barMargin = b;
- if (!a) {
- this.refreshKeepingScroll()
- }
- },
- setRowHeight : function(a, b) {
- this.rowHeight = a || 24;
- if (this.rendered && !b) {
- this.refreshKeepingScroll()
- }
- },
- refreshKeepingScroll : function(a) {
- this.saveScrollState();
- if (this.lightRefresh) {
- this.lightRefresh()
- } else {
- this.refresh()
- }
- this.restoreScrollState()
- },
- refreshKeepingResourceScroll : function(c) {
- var d = this.el.dom, b = d.scrollTop, a = d.scrollLeft;
- if (this.lightRefresh) {
- this.lightRefresh()
- } else {
- this.refresh()
- }
- if (this.getOrientation() === "horizontal") {
- d.scrollTop = b
- } else {
- d.scrollLeft = a
- }
- },
- lightRefresh : function() {
- var a = this.refreshSize;
- Ext.suspendLayouts();
- this.refreshSize = Ext.emptyFn;
- this.__lightRefresh = true;
- this.refresh();
- delete this.__lightRefresh;
- this.refreshSize = a;
- Ext.resumeLayouts()
- }
- }, function() {
- Ext.apply(Sch, {
- VERSION : "2.1.11"
- })
- });
- Ext.define("Sch.view.Horizontal", {
- props : {
- translateToScheduleCoordinate : function(a) {
- return a - this.el.getX() + this.el.getScroll().left
- },
- translateToPageCoordinate : function(a) {
- return a + this.el.getX() - this.el.getScroll().left
- },
- getDateFromXY : function(h, f, e) {
- var b, a = e ? h[0] : this.translateToScheduleCoordinate(h[0]), d = a
- / this.getActualTimeColumnWidth(), c = this.timeAxis
- .getCount();
- if (d < 0 || d > c) {
- b = null
- } else {
- var g = d - this.resolveColumnIndex(a);
- if (g > 2 && d >= c) {
- return null
- }
- b = this.timeAxis.getDateFromTick(d, f)
- }
- return b
- },
- getXYFromDate : function(b, d) {
- var a, c = this.timeAxis.getTickFromDate(b);
- if (c >= 0) {
- a = this.getActualTimeColumnWidth() * c
- }
- if (d === false) {
- a = this.translateToPageCoordinate(a)
- }
- return [Math.round(a), 0]
- },
- getEventBox : function(e, b) {
- var a = Math.floor(this.getXYFromDate(e)[0]), c = Math.floor(this
- .getXYFromDate(b)[0]), d = Math;
- if (this.managedEventSizing) {
- return {
- top : Math.max(0, (this.barMargin
- - (Ext.isIE && !Ext.isStrict)
- ? 0
- : this.eventBorderWidth
- - this.cellBorderWidth)),
- left : d.min(a, c),
- width : d.max(1, d.abs(a - c) - this.eventBorderWidth),
- height : this.rowHeight - (2 * this.barMargin)
- - this.eventBorderWidth
- }
- }
- return {
- left : d.min(a, c),
- width : d.max(1, d.abs(a - c))
- }
- },
- layoutEvents : function(a) {
- var c = Ext.Array.clone(a);
- c.sort(this.sortEvents);
- var b = this.layoutEventsInBands(0, c);
- return b
- },
- layoutEventsInBands : function(d, a) {
- var c = a[0], b = d === 0
- ? this.barMargin
- : (d * this.rowHeight - ((d - 1) * this.barMargin));
- if (b >= this.cellBorderWidth) {
- b -= this.cellBorderWidth
- }
- while (c) {
- c.top = b;
- Ext.Array.remove(a, c);
- c = this.findClosestSuccessor(c, a)
- }
- d++;
- if (a.length > 0) {
- return this.layoutEventsInBands(d, a)
- } else {
- return d
- }
- },
- getScheduleRegion : function(d, f) {
- var h = d ? Ext.fly(this.getNodeByRecord(d)).getRegion() : this.el
- .down(".x-grid-table").getRegion(), e = this.timeAxis
- .getStart(), j = this.timeAxis.getEnd(), b = this
- .getDateConstraints(d, f)
- || {
- start : e,
- end : j
- }, c = this.translateToPageCoordinate(this
- .getXYFromDate(b.start)[0]), i = this
- .translateToPageCoordinate(this.getXYFromDate(b.end)[0])
- - this.eventBorderWidth, g = h.top + this.barMargin, a = h.bottom
- - this.barMargin - this.eventBorderWidth;
- return new Ext.util.Region(g, Math.max(c, i), a, Math.min(c, i))
- },
- getResourceRegion : function(h, d, g) {
- var k = Ext.fly(this.getNodeByRecord(h)).getRegion(), i = this.timeAxis
- .getStart(), n = this.timeAxis.getEnd(), c = d
- ? Sch.util.Date.max(i, d)
- : i, e = g ? Sch.util.Date.min(n, g) : n, f = this
- .getXYFromDate(c)[0], m = this.getXYFromDate(e)[0]
- - this.eventBorderWidth, l = this.el.getTop(), b = this.el
- .getScroll(), j = k.top + 1 - l + b.top, a = k.bottom - 1
- - l + b.top;
- return new Ext.util.Region(j, Math.max(f, m), a, Math.min(f, m))
- },
- collectRowData : function(g, p, o) {
- var c = this.eventStore.getEventsForResource(p);
- if (c.length === 0 || this.headerCt.getColumnCount() === 0) {
- g.rowHeight = this.rowHeight;
- return g
- }
- var a = Sch.util.Date, m = this.timeAxis, n = m.getStart(), r = m
- .getEnd(), k = [], j, f;
- for (j = 0, f = c.length; j < f; j++) {
- var b = c[j], d = b.getStartDate(), h = b.getEndDate();
- if (d && h && m.timeSpanInAxis(d, h)) {
- var q = this.generateTplData(b, n, r, p, o);
- k[k.length] = q
- }
- }
- var e = 1;
- if (this.dynamicRowHeight) {
- e = this.layoutEvents(k)
- }
- g.rowHeight = (e * this.rowHeight) - ((e - 1) * this.barMargin);
- g[this.getFirstTimeColumn().id] += " "
- + this.eventTpl.apply(k);
- return g
- },
- resolveResource : function(a) {
- var b = this.findItemByChild(a);
- if (b) {
- return this.getRecord(b)
- }
- return null
- },
- getTimeSpanRegion : function(b, h, g) {
- var d = this.getXYFromDate(b)[0], f = this.getXYFromDate(h || b)[0], a, c;
- if (this.store.buffered) {
- var e;
- if (this.panel.verticalScroller.stretcher instanceof Ext.CompositeElement) {
- e = this.panel.verticalScroller.stretcher.first()
- } else {
- e = this.el.down(".x-stretcher")
- }
- if (e.dom.clientHeight) {
- c = e
- }
- }
- if (!c) {
- c = this.el.down(".x-grid-table")
- }
- if (g) {
- a = Math.max(c ? c.dom.clientHeight : 0,
- this.el.dom.clientHeight)
- } else {
- a = c ? c.dom.clientHeight : 0
- }
- return new Ext.util.Region(0, Math.max(d, f), a, Math.min(d, f))
- },
- getStartEndDatesFromRegion : function(c, b) {
- var a = this.getDateFromXY([c.left, 0], b), d = this.getDateFromXY(
- [c.right, 0], b);
- if (d && a) {
- return {
- start : Sch.util.Date.min(a, d),
- end : Sch.util.Date.max(a, d)
- }
- } else {
- return null
- }
- },
- onEventAdd : function(m, h) {
- var e = {};
- for (var g = 0, c = h.length; g < c; g++) {
- var a = h[g].getResources();
- for (var f = 0, d = a.length; f < d; f++) {
- var b = a[f];
- e[b.getId()] = b
- }
- }
- Ext.Object.each(e, function(j, i) {
- this.onUpdate(this.resourceStore, i)
- }, this)
- },
- onEventRemove : function(e, b) {
- var h = b.getResources();
- var f = this.resourceStore;
- var a = Ext.tree.View && this instanceof Ext.tree.View;
- var d = function(i) {
- if (a && this.store.indexOf(i)) {
- this.onUpdate(this.store, i)
- } else {
- if (f.indexOf(i) >= 0) {
- this.onUpdate(f, i)
- }
- }
- };
- if (h.length > 1) {
- Ext.each(h, d, this)
- } else {
- var c = this.getElementFromEventRecord(b);
- if (c) {
- var g = this.resolveResource(c);
- c.fadeOut({
- callback : function() {
- d.call(this, g)
- },
- scope : this
- })
- }
- }
- },
- onEventUpdate : function(b, c, a) {
- var d = c.previous;
- if (d && d[c.resourceIdField]) {
- var e = c.getResource(d[c.resourceIdField]);
- if (e) {
- this.onUpdate(this.resourceStore, e)
- }
- }
- var f = c.getResources();
- Ext.each(f, function(g) {
- this.onUpdate(this.resourceStore, g)
- }, this)
- },
- getSingleTickInPixels : function() {
- return this.getActualTimeColumnWidth()
- },
- getColumnWidth : function() {
- if (this.getTimeAxisColumn()) {
- return this.getTimeAxisColumn().getTimeColumnWidth()
- }
- },
- setColumnWidth : function(b, a) {
- if (this.getTimeAxisColumn()) {
- this.getTimeAxisColumn().setTimeColumnWidth(b);
- if (!a) {
- this.refreshKeepingScroll()
- }
- }
- this.fireEvent("columnwidthchange", this, b)
- },
- getVisibleDateRange : function() {
- if (!this.rendered) {
- return null
- }
- var c = this.getEl().getScroll(), b = this.panel.getStart(), f = this.panel
- .getEnd(), e = this.getWidth(), d = this.getEl()
- .down(".x-grid-table").dom, a = d.clientWidth;
- if (a < e) {
- return {
- startDate : b,
- endDate : f
- }
- }
- return {
- startDate : this.getDateFromXY([c.left, 0], null, true),
- endDate : this.getDateFromXY([Math.min(c.left + e, a), 0],
- null, true)
- }
- }
- }
- });
- Ext.define("Sch.mixin.FilterableTreeView", {
- initTreeFiltering : function() {
- var a = function() {
- var b = this.up("tablepanel").store;
- this.mon(b, "nodestore-datachange-start",
- this.onFilterChangeStart, this);
- this.mon(b, "nodestore-datachange-end",
- this.onFilterChangeEnd, this);
- this.mon(b, "filter-clear", this.onFilterCleared, this);
- this.mon(b, "filter-set", this.onFilterSet, this)
- };
- if (this.rendered) {
- a.call(this)
- } else {
- this.on("beforerender", a, this, {
- single : true
- })
- }
- },
- onFilterChangeStart : function() {
- Ext.suspendLayouts()
- },
- onFilterChangeEnd : function() {
- Ext.resumeLayouts()
- },
- onFilterCleared : function() {
- delete this.toggle;
- var a = this.getEl();
- if (a) {
- a.removeCls("sch-tree-filtered")
- }
- },
- onFilterSet : function() {
- this.toggle = function() {
- };
- var a = this.getEl();
- if (a) {
- a.addCls("sch-tree-filtered")
- }
- }
- });
- Ext.define("Sch.view.TimelineTreeView", {
- extend : "Ext.tree.View",
- mixins : ["Sch.mixin.TimelineView", "Sch.mixin.FilterableTreeView"],
- requires : ["Sch.patches.TreeView"],
- cellBorderWidth : 0,
- constructor : function() {
- this.callParent(arguments);
- this.initTreeFiltering()
- }
- }, function() {
- this
- .override(Sch.mixin.TimelineView.prototype.inheritables()
- || {})
- });
- Ext.define("Sch.mixin.Zoomable", {
- zoomLevels : [{
- width : 30,
- increment : 1,
- resolution : 1,
- preset : "year",
- resolutionUnit : "MONTH"
- }, {
- width : 50,
- increment : 1,
- resolution : 1,
- preset : "year",
- resolutionUnit : "MONTH"
- }, {
- width : 100,
- increment : 1,
- resolution : 1,
- preset : "year",
- resolutionUnit : "MONTH"
- }, {
- width : 200,
- increment : 1,
- resolution : 1,
- preset : "year",
- resolutionUnit : "MONTH"
- }, {
- width : 100,
- increment : 1,
- resolution : 7,
- preset : "monthAndYear",
- resolutionUnit : "DAY"
- }, {
- width : 30,
- increment : 1,
- resolution : 1,
- preset : "weekDateAndMonth",
- resolutionUnit : "DAY"
- }, {
- width : 35,
- increment : 1,
- resolution : 1,
- preset : "weekAndMonth",
- resolutionUnit : "DAY"
- }, {
- width : 50,
- increment : 1,
- resolution : 1,
- preset : "weekAndMonth",
- resolutionUnit : "DAY"
- }, {
- width : 20,
- increment : 1,
- resolution : 1,
- preset : "weekAndDayLetter"
- }, {
- width : 50,
- increment : 1,
- resolution : 1,
- preset : "weekAndDay",
- resolutionUnit : "HOUR"
- }, {
- width : 100,
- increment : 1,
- resolution : 1,
- preset : "weekAndDay",
- resolutionUnit : "HOUR"
- }, {
- width : 50,
- increment : 6,
- resolution : 30,
- preset : "hourAndDay",
- resolutionUnit : "MINUTE"
- }, {
- width : 100,
- increment : 6,
- resolution : 30,
- preset : "hourAndDay",
- resolutionUnit : "MINUTE"
- }, {
- width : 60,
- increment : 2,
- resolution : 30,
- preset : "hourAndDay",
- resolutionUnit : "MINUTE"
- }, {
- width : 60,
- increment : 1,
- resolution : 30,
- preset : "hourAndDay",
- resolutionUnit : "MINUTE"
- }, {
- width : 30,
- increment : 15,
- resolution : 5,
- preset : "minuteAndHour"
- }, {
- width : 60,
- increment : 15,
- resolution : 5,
- preset : "minuteAndHour"
- }, {
- width : 130,
- increment : 15,
- resolution : 5,
- preset : "minuteAndHour"
- }, {
- width : 60,
- increment : 5,
- resolution : 5,
- preset : "minuteAndHour"
- }, {
- width : 100,
- increment : 5,
- resolution : 5,
- preset : "minuteAndHour"
- }],
- minZoomLevel : null,
- maxZoomLevel : null,
- visibleZoomFactor : 5,
- cachedCenterDate : null,
- isFirstZoom : true,
- isZooming : false,
- initializeZooming : function() {
- this.zoomLevels = this.zoomLevels.slice();
- this.setMinZoomLevel(this.minZoomLevel || 0);
- this.setMaxZoomLevel(this.maxZoomLevel !== null
- ? this.maxZoomLevel
- : this.zoomLevels.length - 1);
- this.on("viewchange", this.clearCenterDateCache, this)
- },
- getZoomLevelUnit : function(b) {
- var a = Sch.preset.Manager.getPreset(b.preset).headerConfig;
- return a.bottom ? a.bottom.unit : a.middle.unit
- },
- getMilliSecondsPerPixelForZoomLevel : function(b) {
- var a = Sch.util.Date;
- return Math.round((a.add(new Date(1, 0, 1), this.getZoomLevelUnit(b),
- b.increment) - new Date(1, 0, 1))
- / b.width)
- },
- presetToZoomLevel : function(e) {
- var d = Sch.preset.Manager.getPreset(e);
- var c = d.headerConfig;
- var a = c.bottom;
- var b = c.middle;
- return {
- preset : e,
- increment : (a ? a.increment : b.increment) || 1,
- resolution : d.timeResolution.increment,
- resolutionUnit : d.timeResolution.unit,
- width : d.timeColumnWidth
- }
- },
- calculateCurrentZoomLevel : function() {
- var d = this.presetToZoomLevel(this.viewPreset);
- var c = this.timeAxis.headerConfig;
- var a = c.bottom;
- var b = c.middle;
- d.width = this.timeAxis.preset.timeColumnWidth;
- d.increment = (a ? a.increment : b.increment) || 1;
- return d
- },
- getCurrentZoomLevelIndex : function() {
- var f = this.calculateCurrentZoomLevel();
- var b = this.getMilliSecondsPerPixelForZoomLevel(f);
- var e = this.zoomLevels;
- for (var c = 0; c < e.length; c++) {
- var d = this.getMilliSecondsPerPixelForZoomLevel(e[c]);
- if (d == b) {
- return c
- }
- if (c === 0 && b > d) {
- return -0.5
- }
- if (c == e.length - 1 && b < d) {
- return e.length - 1 + 0.5
- }
- var a = this.getMilliSecondsPerPixelForZoomLevel(e[c + 1]);
- if (d > b && b > a) {
- return c + 0.5
- }
- }
- throw "Can't find current zoom level index"
- },
- setMaxZoomLevel : function(a) {
- if (a < 0 || a >= this.zoomLevels.length) {
- throw new Error("Invalid range for `setMinZoomLevel`")
- }
- this.maxZoomLevel = a
- },
- setMinZoomLevel : function(a) {
- if (a < 0 || a >= this.zoomLevels.length) {
- throw new Error("Invalid range for `setMinZoomLevel`")
- }
- this.minZoomLevel = a
- },
- getViewportCenterDateCached : function() {
- if (this.cachedCenterDate) {
- return this.cachedCenterDate
- }
- return this.cachedCenterDate = this.getViewportCenterDate()
- },
- clearCenterDateCache : function() {
- this.cachedCenterDate = null
- },
- zoomToLevel : function(b) {
- b = Ext.Number.constrain(b, this.minZoomLevel, this.maxZoomLevel);
- var n = this.calculateCurrentZoomLevel();
- var d = this.getMilliSecondsPerPixelForZoomLevel(n);
- var i = this.zoomLevels[b];
- var a = this.getMilliSecondsPerPixelForZoomLevel(i);
- if (d == a) {
- return null
- }
- var p = this;
- var j = this.getSchedulingView();
- var f = j.getEl();
- if (this.isFirstZoom) {
- this.isFirstZoom = false;
- f.on("scroll", this.clearCenterDateCache, this)
- }
- var h = this.orientation == "vertical";
- var e = this.getViewportCenterDateCached();
- var k = h ? f.getHeight() : f.getWidth();
- var l = Ext.clone(Sch.preset.Manager.getPreset(i.preset));
- var o = this.calculateOptimalDateRange(e, k, i);
- var c = l.headerConfig;
- var g = c.bottom;
- var r = c.middle;
- l[h ? "rowHeight" : "timeColumnWidth"] = i.width;
- if (g) {
- g.increment = i.increment
- } else {
- r.increment = i.increment
- }
- this.isZooming = true;
- this.viewPreset = i.preset;
- var m = g ? g.unit : r.unit;
- this.timeAxis.reconfigure({
- preset : l,
- headerConfig : c,
- unit : m,
- increment : i.increment,
- resolutionUnit : Sch.util.Date.getUnitByName(i.resolutionUnit || m),
- resolutionIncrement : i.resolution,
- weekStartDay : this.weekStartDay,
- mainUnit : r.unit,
- shiftUnit : l.shiftUnit,
- shiftIncrement : l.shiftIncrement || 1,
- defaultSpan : l.defaultSpan || 1,
- start : o.startDate || this.getStart(),
- end : o.endDate || this.getEnd()
- });
- var q = j.getXYFromDate(e, true);
- f.on("scroll", function() {
- p.cachedCenterDate = e
- }, this, {
- single : true
- });
- if (h) {
- f.scrollTo("top", q[1] - k / 2)
- } else {
- f.scrollTo("left", q[0] - k / 2)
- }
- p.isZooming = false;
- this.fireEvent("zoomchange", this, b);
- return b
- },
- zoomIn : function(a) {
- a = a || 1;
- var b = this.getCurrentZoomLevelIndex();
- if (b >= this.zoomLevels.length - 1) {
- return null
- }
- return this.zoomToLevel(Math.floor(b) + a)
- },
- zoomOut : function(a) {
- a = a || 1;
- var b = this.getCurrentZoomLevelIndex();
- if (b <= 0) {
- return null
- }
- return this.zoomToLevel(Math.ceil(b) - a)
- },
- zoomInFull : function() {
- return this.zoomToLevel(this.maxZoomLevel)
- },
- zoomOutFull : function() {
- return this.zoomToLevel(this.minZoomLevel)
- },
- calculateOptimalDateRange : function(c, h, e) {
- var b = Sch.util.Date;
- var i = Sch.preset.Manager.getPreset(e.preset).headerConfig;
- var f = i.top ? i.top.unit : i.middle.unit;
- var j = this.getZoomLevelUnit(e);
- var d = Math.ceil(h / e.width * e.increment * this.visibleZoomFactor
- / 2);
- var a = b.add(c, j, -d);
- var g = b.add(c, j, d);
- return {
- startDate : this.timeAxis.floorDate(a, false, f),
- endDate : this.timeAxis.ceilDate(g, false, f)
- }
- }
- });
- Ext.define("Sch.mixin.TimelinePanel", {
- requires : ["Sch.util.Patch", "Sch.patches.LoadMask", "Sch.patches.Model",
- "Sch.patches.Table", "Sch.data.TimeAxis",
- "Sch.feature.ColumnLines", "Sch.view.Locking",
- "Sch.mixin.Lockable", "Sch.preset.Manager"],
- mixins : ["Sch.mixin.Zoomable"],
- orientation : "horizontal",
- weekStartDay : 1,
- snapToIncrement : false,
- readOnly : false,
- eventResizeHandles : "both",
- viewPreset : "weekAndDay",
- trackHeaderOver : true,
- startDate : null,
- endDate : null,
- eventBorderWidth : 1,
- tooltipTpl : null,
- tipCfg : {
- cls : "sch-tip",
- showDelay : 1000,
- hideDelay : 0,
- autoHide : true,
- anchor : "b"
- },
- lightWeight : true,
- timeCellRenderer : null,
- timeCellRendererScope : null,
- inheritables : function() {
- return {
- columnLines : true,
- enableColumnMove : false,
- enableLocking : true,
- lockable : true,
- lockedXType : null,
- normalXType : null,
- initComponent : function() {
- this.lightWeight = this.lightWeight && !this.timeCellRenderer;
- this.addEvents("timeheaderdblclick", "beforeviewchange",
- "viewchange");
- if (!this.timeAxis) {
- this.timeAxis = Ext.create("Sch.data.TimeAxis")
- }
- if (!this.columns && !this.colModel) {
- this.columns = []
- }
- this.timeAxis.on("reconfigure", this.onTimeAxisReconfigure,
- this);
- if (this.enableLocking) {
- this.self.mixin("lockable", Sch.mixin.Lockable);
- var b = 0, a = this.columns.length, c;
- for (; b < a; ++b) {
- c = this.columns[b];
- if (c.locked !== false) {
- c.locked = true
- }
- c.lockable = false
- }
- this.switchViewPreset(this.viewPreset, this.startDate
- || this.timeAxis.getStart(), this.endDate
- || this.timeAxis.getEnd(), true)
- }
- this.callParent(arguments);
- if (this.lockable) {
- this.applyViewSettings(this.timeAxis.preset);
- if (!this.viewPreset) {
- throw "You must define a valid view preset object. See Sch.preset.Manager class for reference"
- }
- if (this.lightWeight && this.columnLines) {
- this.columnLinesFeature = new Sch.feature.ColumnLines();
- this.columnLinesFeature.init(this)
- }
- }
- this.initializeZooming();
- this.relayEvents(this.getView(), ["beforetooltipshow",
- "scheduleclick", "scheduledblclick",
- "schedulecontextmenu"])
- },
- getState : function() {
- var a = this, b = a.callParent(arguments);
- Ext.apply(b, {
- viewPreset : a.viewPreset,
- startDate : a.getStart(),
- endDate : a.getEnd(),
- zoomMinLevel : a.zoomMinLevel,
- zoomMaxLevel : a.zoomMaxLevel,
- currentZoomLevel : a.currentZoomLevel
- });
- return b
- },
- getOrientation : function() {
- return this.orientation
- },
- applyState : function(b) {
- var a = this;
- a.callParent(arguments);
- if (b && b.viewPreset) {
- a.switchViewPreset(b.viewPreset, b.startDate, b.endDate)
- }
- if (b && b.currentZoomLevel) {
- a.zoomToLevel(b.currentZoomLevel)
- }
- },
- beforeRender : function() {
- this.callParent(arguments);
- if (this.lockable) {
- this.addCls("sch-" + this.orientation)
- }
- },
- afterRender : function() {
- this.callParent(arguments);
- if (this.lockable) {
- this.lockedGrid.on("itemdblclick", function(d, c, e, g, f) {
- if (this.orientation == "vertical" && c) {
- this.fireEvent("timeheaderdblclick", this,
- c.get("start"), c.get("end"), g, f)
- }
- }, this)
- } else {
- var b = this.headerCt;
- if (b && b.reorderer && b.reorderer.dropZone) {
- var a = b.reorderer.dropZone;
- a.positionIndicator = Ext.Function.createSequence(
- a.positionIndicator, function() {
- this.valid = false
- })
- }
- }
- },
- delayScroll : function() {
- var a = this.getScrollTarget().el;
- if (a) {
- this.scrollTask.delay(10, function() {
- if (a.dom) {
- this.syncHorizontalScroll(a.dom.scrollLeft)
- }
- }, this)
- }
- }
- }
- },
- setReadOnly : function(a) {
- this.getSchedulingView().setReadOnly(a)
- },
- isReadOnly : function() {
- return this.getSchedulingView().isReadOnly()
- },
- switchViewPreset : function(d, a, f, b) {
- if (this.fireEvent("beforeviewchange", this, d, a, f) !== false) {
- if (Ext.isString(d)) {
- this.viewPreset = d;
- d = Sch.preset.Manager.getPreset(d)
- }
- if (!d) {
- throw "View preset not found"
- }
- var e = d.headerConfig;
- var c = {
- unit : e.bottom ? e.bottom.unit : e.middle.unit,
- increment : (e.bottom ? e.bottom.increment : e.middle.increment)
- || 1,
- resolutionUnit : d.timeResolution.unit,
- resolutionIncrement : d.timeResolution.increment,
- weekStartDay : this.weekStartDay,
- mainUnit : e.middle.unit,
- shiftUnit : d.shiftUnit,
- headerConfig : d.headerConfig,
- shiftIncrement : d.shiftIncrement || 1,
- preset : d,
- defaultSpan : d.defaultSpan || 1
- };
- if (b) {
- if (this.timeAxis.getCount() === 0 || a) {
- c.start = a || new Date();
- c.end = f
- }
- } else {
- c.start = a || this.timeAxis.getStart();
- c.end = f
- }
- if (!b) {
- this.applyViewSettings(d)
- }
- this.timeAxis.reconfigure(c)
- }
- },
- applyViewSettings : function(b) {
- var a = this.getSchedulingView();
- a.setDisplayDateFormat(b.displayDateFormat);
- if (this.orientation === "horizontal") {
- a.setRowHeight(this.rowHeight || b.rowHeight, true)
- }
- },
- getStart : function() {
- return this.timeAxis.getStart()
- },
- getEnd : function() {
- return this.timeAxis.getEnd()
- },
- getViewportCenterDate : function() {
- var b = this.getSchedulingView(), c = b.getEl(), a = c.getScroll(), d;
- if (this.orientation === "vertical") {
- d = [0, a.top + c.getHeight() / 2]
- } else {
- d = [a.left + c.getWidth() / 2, 0]
- }
- return b.getDateFromXY(d, null, true)
- },
- setTimeColumnWidth : function(b, a) {
- this.getSchedulingView().setColumnWidth(b, a)
- },
- onTimeAxisReconfigure : function() {
- this.fireEvent("viewchange", this);
- if (this.stateful && this.lockedGrid) {
- this.saveState()
- }
- },
- getColumnsState : function() {
- var b = this, a = b.lockedGrid.headerCt.getColumnsState();
- return a
- },
- shiftNext : function(a) {
- this.timeAxis.shiftNext(a)
- },
- shiftPrevious : function(a) {
- this.timeAxis.shiftPrevious(a)
- },
- goToNow : function() {
- this.setTimeSpan(new Date())
- },
- setTimeSpan : function(b, a) {
- if (this.timeAxis) {
- this.timeAxis.setTimeSpan(b, a)
- }
- },
- setStart : function(a) {
- this.setTimeSpan(a)
- },
- setEnd : function(a) {
- this.setTimeSpan(null, a)
- },
- getTimeAxis : function() {
- return this.timeAxis
- },
- getResourceByEventRecord : function(a) {
- return a.getResource()
- },
- scrollToDate : function(c, b) {
- var a = this.getSchedulingView(), d = a.getXYFromDate(c, true);
- if (this.orientation == "horizontal") {
- a.getEl().scrollTo("left", Math.max(0, d[0]), b)
- } else {
- a.getEl().scrollTo("top", Math.max(0, d[1]), b)
- }
- },
- getSchedulingView : function() {
- return this.lockable ? this.normalGrid.getView() : this.getView()
- },
- setOrientation : function(a) {
- this.removeCls("sch-" + this.orientation);
- this.addCls("sch-" + a);
- this.orientation = a
- }
- });
- Ext.define("Sch.panel.TimelineTreePanel", {
- extend : "Ext.tree.Panel",
- requires : ["Ext.data.TreeStore"],
- mixins : ["Sch.mixin.TimelinePanel"],
- useArrows : true,
- rootVisible : false,
- constructor : function(a) {
- a = a || {};
- a.animate = false;
- this.callParent(arguments)
- },
- initComponent : function() {
- this.callParent(arguments);
- if (this.lockable
- && this.lockedGrid.headerCt.query("treecolumn").length === 0) {
- Ext.Error
- .raise("You must define an Ext.tree.Column (or use xtype : 'treecolumn').")
- }
- },
- onRootChange : function(a) {
- if (!this.lockable) {
- this.callParent(arguments)
- }
- },
- bindStore : function(b) {
- this.callParent(arguments);
- if (Ext.getVersion("extjs").isGreaterThanOrEqual("4.1.2")) {
- var c = this, a = c.getView();
- if (b.buffered && c.verticalScroll) {
- c.verticalScroller = new Ext.grid.PagingScroller(Ext.apply({
- panel : c,
- store : b,
- view : c.view
- }, c.initialConfig.verticalScroller))
- }
- if (b && b.buffered) {
- a.preserveScrollOnRefresh = true
- } else {
- if (c.invalidateScrollerOnRefresh !== undefined) {
- a.preserveScrollOnRefresh = !c.invalidateScrollerOnRefresh
- }
- }
- }
- }
- }, function() {
- this.override(Sch.mixin.TimelinePanel.prototype.inheritables() || {})
- });
- Ext.define("Sch.plugin.Printable", {
- extend : "Ext.AbstractPlugin",
- lockableScope : "top",
- docType : "<!DOCTYPE HTML>",
- beforePrint : Ext.emptyFn,
- afterPrint : Ext.emptyFn,
- autoPrintAndClose : true,
- fakeBackgroundColor : true,
- scheduler : null,
- constructor : function(a) {
- Ext.apply(this, a)
- },
- init : function(a) {
- this.scheduler = a;
- a.print = Ext.Function.bind(this.print, this)
- },
- mainTpl : new Ext.XTemplate(
- '{docType}<html class="x-border-box {htmlClasses}"><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /><title>{title}</title>{styles}</head><body class="sch-print-body {bodyClasses}"><div class="sch-print-ct {componentClasses}" style="width:{totalWidth}px"><div class="sch-print-headerbg" style="border-left-width:{totalWidth}px;height:{headerHeight}px;"></div><div class="sch-print-header-wrap">{[this.printLockedHeader(values)]}{[this.printNormalHeader(values)]}</div>{[this.printLockedGrid(values)]}{[this.printNormalGrid(values)]}</div><script type="text/javascript">{setupScript}<\/script></body></html>',
- {
- printLockedHeader : function(a) {
- var b = "";
- if (a.lockedGrid) {
- b += '<div style="left:-' + a.lockedScroll
- + "px;margin-right:-" + a.lockedScroll
- + "px;width:"
- + (a.lockedWidth + a.lockedScroll) + 'px"';
- b += 'class="sch-print-lockedheader x-grid-header-ct x-grid-header-ct-default x-docked x-docked-top x-grid-header-ct-docked-top x-grid-header-ct-default-docked-top x-box-layout-ct x-docked-noborder-top x-docked-noborder-right x-docked-noborder-left">';
- b += a.lockedHeader;
- b += "</div>"
- }
- return b
- },
- printNormalHeader : function(a) {
- var b = "";
- if (a.normalGrid) {
- b += '<div style="left:'
- + (a.lockedGrid ? a.lockedWidth : "0")
- + "px;width:"
- + a.normalWidth
- + 'px;" class="sch-print-normalheader x-grid-header-ct x-grid-header-ct-default x-docked x-docked-top x-grid-header-ct-docked-top x-grid-header-ct-default-docked-top x-box-layout-ct x-docked-noborder-top x-docked-noborder-right x-docked-noborder-left">';
- b += '<div style="margin-left:-' + a.normalScroll
- + 'px">' + a.normalHeader + "</div>";
- b += "</div>"
- }
- return b
- },
- printLockedGrid : function(a) {
- var b = "";
- if (a.lockedGrid) {
- b += '<div id="lockedRowsCt" style="left:-'
- + a.lockedScroll + "px;margin-right:-"
- + a.lockedScroll + "px;width:" + a.lockedWidth
- + a.lockedScroll + "px;top:" + a.headerHeight
- + 'px;" class="sch-print-locked-rows-ct '
- + a.innerLockedClasses
- + ' x-grid-inner-locked">';
- b += a.lockedRows;
- b += "</div>"
- }
- return b
- },
- printNormalGrid : function(a) {
- var b = "";
- if (a.normalGrid) {
- b += '<div id="normalRowsCt" style="left:'
- + (a.lockedGrid ? a.lockedWidth : "0")
- + "px;top:" + a.headerHeight + "px;width:"
- + a.normalWidth
- + 'px" class="sch-print-normal-rows-ct '
- + a.innerNormalClasses + '">';
- b += '<div style="position:relative;overflow:visible;margin-left:-'
- + a.normalScroll
- + 'px">'
- + a.normalRows
- + "</div>";
- b += "</div>"
- }
- return b
- }
- }),
- getGridContent : function(l) {
- var k = l.normalGrid, d = l.lockedGrid, m = d.getView(), e = k
- .getView(), h, c, j, g, i, a, f;
- this.beforePrint(l);
- if (d.collapsed && !k.collapsed) {
- a = d.getWidth() + k.getWidth()
- } else {
- a = k.getWidth();
- f = d.getWidth()
- }
- var b = m.store.getRange();
- c = m.tpl.apply(m.collectData(b, 0));
- j = e.tpl.apply(e.collectData(b, 0));
- g = m.el.getScroll().left;
- i = e.el.getScroll().left;
- if (Sch.feature && Sch.feature.AbstractTimeSpan) {
- Ext.each((l.normalGrid.plugins || []).concat(l.columnLinesFeature
- || []), function(n) {
- if (n instanceof Sch.feature.AbstractTimeSpan) {
- j = n.generateMarkup(true) + j
- }
- })
- }
- this.afterPrint(l);
- return {
- normalHeader : k.headerCt.el.dom.innerHTML,
- lockedHeader : d.headerCt.el.dom.innerHTML,
- lockedGrid : !d.collapsed,
- normalGrid : !k.collapsed,
- lockedRows : c,
- normalRows : j,
- lockedScroll : g,
- normalScroll : i,
- lockedWidth : f,
- normalWidth : a,
- headerHeight : k.headerCt.getHeight(),
- innerLockedClasses : d.view.el.dom.className,
- innerNormalClasses : k.view.el.dom.className
- + (this.fakeBackgroundColor
- ? " sch-print-fake-background"
- : ""),
- width : l.getWidth()
- }
- },
- getStylesheets : function() {
- return Ext.getDoc().select('link[rel="stylesheet"]')
- },
- print : function() {
- var g = this.scheduler;
- if (!(this.mainTpl instanceof Ext.Template)) {
- var a = 22;
- this.mainTpl = Ext.create("Ext.XTemplate", this.mainTpl, {
- compiled : true,
- disableFormats : true
- })
- }
- var h = g.getView(), i = this.getStylesheets(), e = Ext
- .get(Ext.core.DomHelper.createDom({
- tag : "div"
- })), b;
- i.each(function(j) {
- e.appendChild(j.dom.cloneNode(true))
- });
- b = e.dom.innerHTML + "";
- var f = this.getGridContent(g), c = this.mainTpl.apply(Ext.apply({
- waitText : this.waitText,
- docType : this.docType,
- htmlClasses : "",
- bodyClasses : Ext.getBody().dom.className,
- componentClasses : g.el.dom.className,
- title : (g.title || ""),
- styles : b,
- totalWidth : g.getWidth(),
- setupScript : "(" + this.setupScript.toString() + ")();"
- }, f));
- var d = window.open("", "printgrid");
- this.printWindow = d;
- d.document.write(c);
- d.document.close();
- if (this.autoPrintAndClose) {
- d.print();
- if (!Ext.isChrome) {
- d.close()
- }
- }
- },
- setupScript : function() {
- var f = document.getElementById("lockedRowsCt"), d = document
- .getElementById("normalRowsCt"), b = f
- && f.getElementsByTagName("tr"), a = d
- && d.getElementsByTagName("tr"), e = a && b ? a.length : 0, c = 0;
- for (; c < e; c++) {
- b[c].style.height = a[c].style.height
- }
- }
- });
- Ext.define("Sch.plugin.Export", {
- extend : "Ext.util.Observable",
- alternateClassName : "Sch.plugin.PdfExport",
- mixins : ["Ext.AbstractPlugin"],
- lockableScope : "top",
- printServer : undefined,
- tpl : new Ext.XTemplate(
- '<!DOCTYPE html><html class="x-border-box {htmlClasses}"><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /><title>{column}/{row}</title>{styles}</head><body class="x-webkit {bodyClasses}">{[this.showHeader(values)]}<div class="{componentClasses}" style="height:{bodyHeight}px; width:{totalWidth}px; position: relative !important">{HTML}</div></body></html>',
- {
- disableFormats : true,
- showHeader : function(a) {
- if (a.showHeader) {
- return '<div class="sch-export-header" style="width:'
- + a.totalWidth + 'px"><h2>' + a.column + "/"
- + a.row + "</h2></div>"
- }
- return ""
- }
- }),
- exportStatus : false,
- exportDialogClassName : "Sch.widget.ExportDialog",
- exportDialogConfig : {},
- defaultConfig : {
- format : "A4",
- orientation : "portrait",
- range : "complete",
- showHeader : true
- },
- pageSizes : {
- A5 : {
- width : 5.8,
- height : 8.3
- },
- A4 : {
- width : 8.3,
- height : 11.7
- },
- A3 : {
- width : 11.7,
- height : 16.5
- },
- Letter : {
- width : 8.5,
- height : 11
- }
- },
- openAfterExport : true,
- fileFormat : "pdf",
- DPI : 72,
- constructor : function(a) {
- this.callParent(arguments);
- this.addEvents("hidedialogwindow", "showdialogerror",
- "updateprogressbar");
- this.setFileFormat(this.fileFormat)
- },
- init : function(a) {
- this.scheduler = a;
- a.showExportDialog = Ext.Function.bind(this.showExportDialog, this);
- a.doExport = Ext.Function.bind(this.doExport, this);
- a.isExporting = Ext.Function.bind(this.isExporting, this)
- },
- setFileFormat : function(a) {
- if (typeof a !== "string") {
- this.fileFormat = "pdf"
- } else {
- a = a.toLowerCase();
- if (a === "png") {
- this.fileFormat = a
- } else {
- this.fileFormat = "pdf"
- }
- }
- },
- isExporting : function() {
- return this.exportStatus
- },
- showExportDialog : function() {
- var b = this, a = b.scheduler.getSchedulingView(), c;
- if (b.win) {
- b.win.destroy();
- b.win = null
- }
- b.win = Ext.create(b.exportDialogClassName, {
- plugin : b,
- exportDialogConfig : Ext.apply({
- startDate : this.scheduler.getStart(),
- endDate : this.scheduler.getEnd(),
- rowHeight : a.rowHeight,
- columnWidth : a.getSingleTickInPixels()
- }, b.exportDialogConfig)
- });
- b.win.show()
- },
- getStylesheets : function() {
- var c = Ext.getDoc().select('link[rel="stylesheet"]'), a = Ext
- .get(Ext.core.DomHelper.createDom({
- tag : "div"
- })), b;
- c.each(function(d) {
- a.appendChild(d.dom.cloneNode(true))
- });
- b = a.dom.innerHTML + "";
- return b
- },
- doExport : function(l, i, n) {
- var A = this, m = A.scheduler, o = m.getSchedulingView(), k = A
- .getStylesheets(), y = l || A.defaultConfig;
- A.exportStatus = true;
- A.mask();
- A.fireEvent("updateprogressbar", 0.1);
- if (m.expandAll) {
- m.expandAll()
- }
- var w = m.lockedGrid, p = m.normalGrid, f = o.rowHeight, z = m.timeAxis
- .getTicks(), q = o.getSingleTickInPixels(), b = {
- width : m.getWidth(),
- height : m.getHeight(),
- rowHeight : f,
- columnWidth : q,
- startDate : m.getStart(),
- endDate : m.getEnd(),
- normalWidth : p.getWidth(),
- normalPosition : p.getPosition()
- }, u, g;
- if (y.orientation === "landscape") {
- u = A.pageSizes[y.format].height * A.DPI;
- g = A.pageSizes[y.format].width * A.DPI
- } else {
- u = A.pageSizes[y.format].width * A.DPI;
- g = A.pageSizes[y.format].height * A.DPI
- }
- var x = 41, t = p.headerCt.getHeight(), e = Math.floor(g) - t
- - (y.showHeader ? x : 0);
- if (y.range !== "complete") {
- var d, a, j, c, r;
- if (y.range === "date") {
- d = new Date(y.dateFrom);
- a = new Date(y.dateTo);
- if (Sch.util.Date.getDurationInDays(d, a < 1)) {
- a = Sch.util.Date.add(a, Sch.util.Date.DAY, 1);
- a = Sch.util.Date.constrain(a, m.getStart(), m.getEnd())
- }
- } else {
- if (y.range === "current") {
- j = o.getVisibleDateRange();
- d = j.startDate;
- a = j.endDate
- }
- }
- c = Math.floor(o.timeAxis.getTickFromDate(d));
- r = Math.floor(o.timeAxis.getTickFromDate(a));
- z = z.filter(function(C, B) {
- return B >= c && B <= r
- });
- m.setTimeSpan(d, a)
- }
- m.setWidth(u);
- m.setTimeColumnWidth(q);
- var h = A.calculatePages(y, z, q, u, e), v = {
- ticks : z,
- printHeight : e,
- paperWidth : u,
- headerHeight : t,
- styles : k,
- config : y
- }, s = A.getExportJsonHtml(h, v);
- A.fireEvent("updateprogressbar", 0.4);
- if (A.printServer) {
- Ext.Ajax.request({
- type : "POST",
- url : A.printServer,
- params : {
- html : {
- array : s
- },
- format : y.format,
- orientation : y.orientation,
- range : y.range,
- fileFormat : A.fileFormat
- },
- success : function(B) {
- A.onSuccess(B, i, n)
- },
- failure : function(B) {
- A.onFailure(B, n)
- },
- scope : A
- })
- } else {
- throw "Server url not defined !"
- }
- A.restorePanel(b)
- },
- calculatePages : function(c, p, h, l, b) {
- var m = this, n = m.scheduler, e = n.lockedGrid, a = n
- .getSchedulingView().rowHeight, k = e.getWidth(), j = Math
- .floor(l / h), g = Math.floor((l - k) / h), d = Math
- .ceil((p.length - g) / j)
- + 1, o = n.getSchedulingView().store.getCount(), i = Math
- .floor(b / a), f = Math.ceil(o / i);
- return {
- columnsAmountLocked : g,
- columnsAmountNormal : j,
- rowsAmount : i,
- rowPages : f,
- columnPages : d,
- timeColumnWidth : h,
- lockedGridWidth : k,
- rowHeight : a,
- panelHTML : {}
- }
- },
- getExportJsonHtml : function(g, B) {
- var E = this, n = E.scheduler, r = g.columnsAmountLocked, t = g.columnsAmountNormal, h = g.rowsAmount, s = g.rowPages, a = g.columnPages, o = g.panelHTML, q = g.timeColumnWidth, A = B.paperWidth, d = B.printHeight, x = B.headerHeight, l = B.styles, C = B.config, D = B.ticks, w = [], j, c, m, e, b, f;
- for (var z = 0; z < a; z += 1) {
- if (z === 0) {
- j = Ext.Number.constrain((r - 1), z, (D.length - 1));
- n.setTimeSpan(D[z].start, D[j].end)
- } else {
- if (!c) {
- c = n.lockedGrid.hide()
- }
- if (D[j + t]) {
- n.setTimeSpan(D[j + 1].start, D[j + t].end);
- j = j + t
- } else {
- n.setTimeSpan(D[j + 1].start, D[D.length - 1].end)
- }
- }
- n.setTimeColumnWidth(q);
- var u = new RegExp(/x-ie\d?|x-gecko/g), y = Ext.getBody().dom.className
- .replace(u, ""), p = n.el.dom.className;
- for (var v = 0; v < s; v += 1) {
- E.hideRows(h, v);
- o.dom = n.body.dom.innerHTML;
- o.k = v;
- o.i = z;
- e = E.resizePanelHTML(o);
- m = E.tpl.apply(Ext.apply({
- bodyClasses : y,
- bodyHeight : d + x,
- componentClasses : p,
- styles : l,
- showHeader : C.showHeader,
- HTML : e.dom.innerHTML,
- totalWidth : A,
- headerHeight : x,
- column : z + 1,
- row : v + 1
- }));
- f = {
- html : m
- };
- w.push(f);
- E.showRows()
- }
- }
- this.exportStatus = false;
- return Ext.JSON.encode(w)
- },
- resizePanelHTML : function(g) {
- var h = Ext.get(Ext.core.DomHelper.createDom({
- tag : "div",
- html : g.dom
- })), c = this.scheduler, f = c.lockedGrid, d = c.normalGrid, e, a;
- if (Ext.isIE6 || Ext.isIE7 || Ext.isIEQuirks) {
- var b = document.createDocumentFragment();
- b.appendChild(h.dom);
- e = [b.getElementById(c.id + "-targetEl"),
- b.getElementById(c.id + "-innerCt"),
- b.getElementById(f.id), b.getElementById(f.body.id),
- b.getElementById(f.body.child(".x-grid-view").id)];
- a = [b.getElementById(d.id), b.getElementById(d.headerCt.id),
- b.getElementById(d.body.id),
- b.getElementById(d.getView().id)];
- Ext.Array.each(e, function(i) {
- if (i !== null) {
- i.style.height = "100%"
- }
- });
- Ext.Array.each(a, function(j, i) {
- if (j !== null) {
- if (i === 1) {
- j.style.width = "100%"
- } else {
- j.style.height = "100%";
- j.style.width = "100%"
- }
- }
- });
- h.dom.innerHTML = b.firstChild.innerHTML
- } else {
- e = [h.select("#" + c.id + "-targetEl").first(),
- h.select("#" + c.id + "-innerCt").first(),
- h.select("#" + f.id).first(),
- h.select("#" + f.body.id).first(),
- h.select("#" + f.body.child(".x-grid-view").id).first()];
- a = [h.select("#" + d.id).first(),
- h.select("#" + d.headerCt.id).first(),
- h.select("#" + d.body.id).first(),
- h.select("#" + d.getView().id).first()];
- Ext.Array.each(e, function(i) {
- if (i) {
- i.setHeight("100%")
- }
- });
- Ext.Array.each(a, function(j, i) {
- if (i === 1) {
- j.setWidth("100%")
- } else {
- j.applyStyles({
- height : "100%",
- width : "100%"
- })
- }
- })
- }
- return h
- },
- getWin : function() {
- return this.win || null
- },
- onSuccess : function(c, h, b) {
- var d = this, g = d.getWin(), a;
- try {
- a = Ext.JSON.decode(c.responseText)
- } catch (f) {
- this.onFailure(c, b);
- return
- }
- d.fireEvent("updateprogressbar", 1);
- if (a.success) {
- setTimeout(function() {
- d.fireEvent("hidedialogwindow");
- d.unmask();
- if (d.openAfterExport) {
- window.open(a.url, "ExportedPanel")
- }
- }, g ? g.hideTime : 3000)
- } else {
- d.fireEvent("showdialogerror", g, a.msg);
- d.unmask()
- }
- if (h) {
- h.call(this, c)
- }
- },
- onFailure : function(b, a) {
- var c = this.getWin();
- this.fireEvent("showdialogerror", c);
- this.unmask();
- if (a) {
- a.call(this, b)
- }
- },
- hideRows : function(d, f) {
- var c = this.scheduler.lockedGrid.getEl().select(".x-grid-row"), a = this.scheduler.normalGrid
- .getEl().select(".x-grid-row"), g = d * f, b = g + d;
- for (var e = 0; e < a.elements.length; e += 1) {
- if (e < g || e >= b) {
- c.elements[e].className += " sch-none";
- a.elements[e].className += " sch-none"
- }
- }
- },
- showRows : function() {
- var b = this.scheduler.lockedGrid.getEl().select(".x-grid-row"), a = this.scheduler.normalGrid
- .getEl().select(".x-grid-row");
- b.each(function(c) {
- c.removeCls("sch-none")
- });
- a.each(function(c) {
- c.removeCls("sch-none")
- })
- },
- mask : function() {
- var a = Ext.getBody().mask();
- a.addCls("sch-export-mask")
- },
- unmask : function() {
- Ext.getBody().unmask()
- },
- restorePanel : function(a) {
- var b = this.scheduler;
- b.setWidth(a.width);
- b.setHeight(a.height);
- b.setTimeSpan(a.startDate, a.endDate);
- b.setTimeColumnWidth(a.columnWidth, true);
- b.getSchedulingView().setRowHeight(a.rowHeight);
- b.lockedGrid.show();
- b.normalGrid.setWidth(a.normalWidth);
- b.normalGrid.setPosition(a.normalPosition[0])
- },
- destroy : function() {
- if (this.win) {
- this.win.destroy()
- }
- }
- });
- Ext.define("Sch.widget.ResizePicker", {
- extend : "Ext.Panel",
- alias : "widget.dualrangepicker",
- width : 200,
- height : 200,
- border : true,
- collapsible : false,
- bodyStyle : "position:absolute; margin:5px",
- verticalCfg : {
- height : 120,
- value : 24,
- increment : 2,
- minValue : 20,
- maxValue : 80,
- reverse : true,
- disabled : true
- },
- horizontalCfg : {
- width : 120,
- value : 100,
- minValue : 25,
- increment : 5,
- maxValue : 200,
- disable : true
- },
- initComponent : function() {
- var a = this;
- a.addEvents("change", "changecomplete", "select");
- a.horizontalCfg.value = a.dialogConfig.columnWidth;
- a.verticalCfg.value = a.dialogConfig.rowHeight;
- a.verticalCfg.disabled = a.dialogConfig.scrollerDisabled || false;
- a.dockedItems = [a.vertical = new Ext.slider.Single(Ext.apply({
- dock : "left",
- style : "margin-top:10px",
- vertical : true,
- listeners : {
- change : a.onSliderChange,
- changecomplete : a.onSliderChangeComplete,
- scope : a
- }
- }, a.verticalCfg)),
- a.horizontal = new Ext.slider.Single(Ext.apply({
- dock : "top",
- style : "margin-left:28px",
- listeners : {
- change : a.onSliderChange,
- changecomplete : a.onSliderChangeComplete,
- scope : a
- }
- }, a.horizontalCfg))];
- a.callParent(arguments)
- },
- afterRender : function() {
- var b = this;
- b.addCls("sch-ux-range-picker");
- b.valueHandle = this.body.createChild({
- cls : "sch-ux-range-value",
- cn : {
- tag : "span"
- }
- });
- b.valueSpan = this.valueHandle.down("span");
- var a = new Ext.dd.DD(this.valueHandle);
- Ext.apply(a, {
- startDrag : function() {
- b.dragging = true;
- this.constrainTo(b.body)
- },
- onDrag : function() {
- b.onHandleDrag.apply(b, arguments)
- },
- endDrag : function() {
- b.onHandleEndDrag.apply(b, arguments);
- b.dragging = false
- },
- scope : this
- });
- this.setValues(this.getValues());
- this.callParent(arguments);
- this.body.on("click", this.onBodyClick, this)
- },
- onBodyClick : function(c, a) {
- var b = [c.getXY()[0] - 8 - this.body.getX(),
- c.getXY()[1] - 8 - this.body.getY()];
- this.valueHandle.setLeft(Ext.Number.constrain(b[0], 0, this
- .getAvailableWidth()));
- this.valueHandle.setTop(Ext.Number.constrain(b[1], 0, this
- .getAvailableHeight()));
- this.setValues(this.getValuesFromXY([this.valueHandle.getLeft(true),
- this.valueHandle.getTop(true)]));
- this.onSliderChangeComplete()
- },
- getAvailableWidth : function() {
- return this.body.getWidth() - 18
- },
- getAvailableHeight : function() {
- return this.body.getHeight() - 18
- },
- onHandleDrag : function() {
- this.setValues(this.getValuesFromXY([this.valueHandle.getLeft(true),
- this.valueHandle.getTop(true)]))
- },
- onHandleEndDrag : function() {
- this.setValues(this.getValuesFromXY([this.valueHandle.getLeft(true),
- this.valueHandle.getTop(true)]))
- },
- getValuesFromXY : function(d) {
- var c = d[0] / this.getAvailableWidth();
- var a = d[1] / this.getAvailableHeight();
- var e = Math
- .round((this.horizontalCfg.maxValue - this.horizontalCfg.minValue)
- * c);
- var b = Math
- .round((this.verticalCfg.maxValue - this.verticalCfg.minValue)
- * a)
- + this.verticalCfg.minValue;
- return [e + this.horizontalCfg.minValue, b]
- },
- getXYFromValues : function(d) {
- var b = this.horizontalCfg.maxValue - this.horizontalCfg.minValue;
- var f = this.verticalCfg.maxValue - this.verticalCfg.minValue;
- var a = Math.round((d[0] - this.horizontalCfg.minValue)
- * this.getAvailableWidth() / b);
- var c = d[1] - this.verticalCfg.minValue;
- var e = Math.round(c * this.getAvailableHeight() / f);
- return [a, e]
- },
- updatePosition : function() {
- var a = this.getValues();
- var b = this.getXYFromValues(a);
- this.valueHandle.setLeft(Ext.Number.constrain(b[0], 0, this
- .getAvailableWidth()));
- if (this.verticalCfg.disabled) {
- this.valueHandle.setTop(this.dialogConfig.rowHeight)
- } else {
- this.valueHandle.setTop(Ext.Number.constrain(b[1], 0, this
- .getAvailableHeight()))
- }
- this.positionValueText();
- this.setValueText(a)
- },
- positionValueText : function() {
- var a = this.valueHandle.getTop(true);
- var b = this.valueHandle.getLeft(true);
- this.valueSpan.setLeft(b > 30 ? -30 : 10);
- this.valueSpan.setTop(a > 10 ? -20 : 20)
- },
- setValueText : function(a) {
- if (this.verticalCfg.disabled) {
- a[1] = this.dialogConfig.rowHeight
- }
- this.valueSpan.update("[" + a.toString() + "]")
- },
- setValues : function(a) {
- this.horizontal.setValue(a[0]);
- if (this.verticalCfg.reverse) {
- if (!this.verticalCfg.disabled) {
- this.vertical.setValue(this.verticalCfg.maxValue
- + this.verticalCfg.minValue - a[1])
- }
- } else {
- if (!this.verticalCfg.disabled) {
- this.vertical.setValue(a[1])
- }
- }
- if (!this.dragging) {
- this.updatePosition()
- }
- this.positionValueText();
- this.setValueText(a)
- },
- getValues : function() {
- var a = this.vertical.getValue();
- if (this.verticalCfg.reverse) {
- a = this.verticalCfg.maxValue - a + this.verticalCfg.minValue
- }
- return [this.horizontal.getValue(), a]
- },
- onSliderChange : function() {
- this.fireEvent("change", this, this.getValues());
- if (!this.dragging) {
- this.updatePosition()
- }
- },
- onSliderChangeComplete : function() {
- this.fireEvent("changecomplete", this, this.getValues())
- },
- afterLayout : function() {
- this.callParent(arguments);
- this.updatePosition()
- }
- });
- Ext.define("Sch.widget.ExportDialogForm", {
- extend : "Ext.form.Panel",
- requires : ["Ext.ProgressBar", "Sch.widget.ResizePicker"],
- border : false,
- bodyPadding : "10 10 0 10",
- autoHeight : true,
- initComponent : function() {
- var a = this;
- a.createFields();
- Ext.apply(this, {
- fieldDefaults : {
- labelAlign : "top",
- labelWidth : 100,
- anchor : "90%"
- },
- items : [a.rangeField, a.resizePicker, a.dateFromField,
- a.dateToField, a.showHeaderField, a.formatField,
- a.orientationField,
- a.progressBar || a.createProgressBar()]
- });
- a.callParent(arguments);
- a.on({
- hideprogressbar : a.hideProgressBar,
- showprogressbar : a.showProgressBar,
- updateprogressbar : a.updateProgressBar,
- scope : a
- })
- },
- createFields : function() {
- var b = this, a = b.dialogConfig;
- b.rangeField = new Ext.form.field.ComboBox({
- xtype : "combo",
- value : "complete",
- triggerAction : "all",
- cls : "sch-export-dialog-range",
- forceSelection : true,
- editable : false,
- fieldLabel : a.rangeFieldLabel,
- name : "range",
- queryMode : "local",
- displayField : "name",
- valueField : "value",
- store : Ext.create("Ext.data.Store", {
- fields : ["name", "value"],
- data : [{
- name : a.completeView,
- value : "complete"
- }, {
- name : a.dateRange,
- value : "date"
- }, {
- name : a.currentView,
- value : "current"
- }]
- }),
- listeners : {
- change : b.onRangeChange,
- scope : b
- }
- });
- b.resizePicker = new Sch.widget.ResizePicker({
- dialogConfig : a,
- hidden : true,
- padding : "0 0 5 0"
- });
- b.dateFromField = new Ext.form.field.Date({
- fieldLabel : a.dateRangeFrom,
- labelAlign : "left",
- labelWidth : 80,
- baseBodyCls : "sch-exportdialogform-date",
- padding : "10 0 5 0",
- name : "dateFrom",
- format : a.dateRangeFormat || Ext.Date.defaultFormat,
- hidden : true,
- allowBlank : false,
- maxValue : a.endDate,
- minValue : a.startDate,
- value : a.startDate,
- validator : function(c) {
- return Ext.Date.parse(c, this.format) >= new Date(a.startDate)
- }
- });
- b.dateToField = new Ext.form.field.Date({
- fieldLabel : a.dateRangeTo,
- labelAlign : "left",
- labelWidth : 80,
- name : "dateTo",
- format : a.dateRangeFormat || Ext.Date.defaultFormat,
- baseBodyCls : "sch-exportdialogform-date",
- hidden : true,
- allowBlank : false,
- maxValue : a.endDate,
- minValue : a.startDate,
- value : a.endDate,
- validator : function(c) {
- return Ext.Date.parse(c, this.format) <= new Date(a.endDate)
- }
- });
- b.showHeaderField = new Ext.form.field.Checkbox({
- xtype : "checkboxfield",
- fieldLabel : b.dialogConfig.showHeaderLabel,
- name : "showHeader",
- checked : true
- });
- b.formatField = new Ext.form.field.ComboBox({
- value : "A4",
- triggerAction : "all",
- forceSelection : true,
- editable : false,
- fieldLabel : a.formatFieldLabel,
- name : "format",
- queryMode : "local",
- store : ["A5", "A4", "A3", "Letter"]
- });
- b.orientationField = new Ext.form.field.ComboBox({
- value : "portrait",
- triggerAction : "all",
- baseBodyCls : "sch-exportdialogform-orientation",
- forceSelection : true,
- editable : false,
- fieldLabel : b.dialogConfig.orientationFieldLabel,
- afterSubTpl : new Ext.XTemplate('<span id="sch-exportdialog-imagePortrait"></span><span id="sch-exportdialog-imageLandscape" class="sch-none"></span>'),
- name : "orientation",
- displayField : "name",
- valueField : "value",
- queryMode : "local",
- store : Ext.create("Ext.data.Store", {
- fields : ["name", "value"],
- data : [{
- name : a.orientationPortrait,
- value : "portrait"
- }, {
- name : a.orientationLandscape,
- value : "landscape"
- }]
- }),
- listeners : {
- change : function(d, c) {
- switch (c) {
- case "landscape" :
- Ext.fly("sch-exportdialog-imagePortrait")
- .toggleCls("sch-none");
- Ext.fly("sch-exportdialog-imageLandscape")
- .toggleCls("sch-none");
- break;
- case "portrait" :
- Ext.fly("sch-exportdialog-imagePortrait")
- .toggleCls("sch-none");
- Ext.fly("sch-exportdialog-imageLandscape")
- .toggleCls("sch-none");
- break
- }
- }
- }
- })
- },
- createProgressBar : function() {
- return this.progressBar = new Ext.ProgressBar({
- text : this.config.progressBarText,
- animate : true,
- hidden : true,
- id : "print-widget-progressbar"
- })
- },
- onRangeChange : function(b, a) {
- switch (a) {
- case "complete" :
- this.dateFromField.hide();
- this.dateToField.hide();
- this.resizePicker.hide();
- break;
- case "date" :
- this.dateFromField.show();
- this.dateToField.show();
- this.resizePicker.hide();
- break;
- case "current" :
- this.dateFromField.hide();
- this.dateToField.hide();
- this.resizePicker.show();
- this.resizePicker.expand(true);
- break
- }
- },
- showProgressBar : function() {
- if (this.progressBar) {
- this.progressBar.show()
- }
- },
- hideProgressBar : function() {
- if (this.progressBar) {
- this.progressBar.hide()
- }
- },
- updateProgressBar : function(a) {
- if (this.progressBar) {
- this.progressBar.updateProgress(a)
- }
- }
- });
- Ext.define("Sch.widget.ExportDialog", {
- alternateClassName : "Sch.widget.PdfExportDialog",
- extend : "Ext.window.Window",
- alias : "widget.exportdialog",
- modal : false,
- width : 240,
- cls : "sch-exportdialog",
- frame : false,
- layout : "card",
- draggable : false,
- padding : 0,
- plugin : null,
- hideTime : 2000,
- buttonsPanel : null,
- buttonsPanelScope : null,
- progressBar : null,
- generalError : "An error occured, try again.",
- title : "Export Settings",
- formatFieldLabel : "Paper format",
- orientationFieldLabel : "Orientation",
- rangeFieldLabel : "Export range",
- showHeaderLabel : "Add page number",
- orientationPortrait : "Portrait",
- orientationLandscape : "Landscape",
- completeView : "Complete schedule",
- currentView : "Current view",
- dateRange : "Date range",
- dateRangeFrom : "Export from",
- pickerText : "Resize column/rows to desired value",
- dateRangeTo : "Export to",
- exportButtonText : "Export",
- cancelButtonText : "Cancel",
- progressBarText : "Exporting...",
- dateRangeFormat : "",
- requires : ["Sch.widget.ExportDialogForm"],
- constructor : function(a) {
- Ext.apply(this, a.exportDialogConfig);
- this.config = Ext.apply({
- progressBarText : this.progressBarText,
- cancelButtonText : this.cancelButtonText,
- exportButtonText : this.exportButtonText,
- dateRangeTo : this.dateRangeTo,
- pickerText : this.pickerText,
- dateRangeFrom : this.dateRangeFrom,
- dateRange : this.dateRange,
- currentView : this.currentView,
- formatFieldLabel : this.formatFieldLabel,
- orientationFieldLabel : this.orientationFieldLabel,
- rangeFieldLabel : this.rangeFieldLabel,
- showHeaderLabel : this.showHeaderLabel,
- orientationPortrait : this.orientationPortrait,
- orientationLandscape : this.orientationLandscape,
- completeView : this.completeView,
- dateRangeFormat : this.dateRangeFormat
- }, a.exportDialogConfig);
- this.callParent(arguments)
- },
- initComponent : function() {
- var b = this, a = {
- hidedialogwindow : b.destroy,
- showdialogerror : b.showError,
- updateprogressbar : function(c) {
- b.fireEvent("updateprogressbar", c)
- },
- scope : this
- };
- Ext.apply(this, {
- items : [b.form = b.buildForm(b.config),
- b.createMessageElement()],
- fbar : b.buildButtons(b.buttonsPanelScope || b)
- });
- b.callParent(arguments);
- b.plugin.on(a)
- },
- afterRender : function() {
- var a = this;
- a.on("changecomplete", function(c, b) {
- a.plugin.scheduler.setTimeColumnWidth(b[0], true);
- if (!a.config.scrollerDisabled) {
- if (a.form.resizePicker.verticalCfg.reverse) {
- var d = b[1];
- a.plugin.scheduler.getSchedulingView()
- .setRowHeight(d)
- } else {
- a.plugin.scheduler.getSchedulingView()
- .setRowHeight(b[1])
- }
- }
- });
- a.relayEvents(a.form.resizePicker, ["change", "changecomplete",
- "select"]);
- a.form.relayEvents(a, ["updateprogressbar", "hideprogressbar",
- "showprogressbar"]);
- a.callParent(arguments);
- a.switchTab(0)
- },
- createMessageElement : function() {
- var a = this;
- return a.messageElement = new Ext.Component({
- autoEl : {
- tag : "div",
- cls : "sch-exportdialog-msg"
- }
- })
- },
- buildButtons : function(a) {
- return [{
- xtype : "button",
- scale : "medium",
- text : this.exportButtonText,
- handler : function() {
- var c = this.form.getForm();
- if (c.isValid()) {
- var b = c.getValues();
- this.fireEvent("showprogressbar");
- this.plugin.doExport(b)
- }
- },
- scope : a
- }, {
- xtype : "button",
- scale : "medium",
- text : this.cancelButtonText,
- handler : function() {
- this.destroy()
- },
- scope : a
- }]
- },
- buildForm : function(a) {
- return new Sch.widget.ExportDialogForm({
- progressBar : this.progressBar,
- dialogConfig : a
- })
- },
- switchTab : function(a) {
- this.getLayout().setActiveItem(a)
- },
- showError : function(b, a) {
- var c = b, d = a || c.generalError;
- c.fireEvent("hideprogressbar");
- c.switchTab(1);
- c.messageElement.getEl().setHTML(d);
- setTimeout(function() {
- c.hide()
- }, c.hideTime)
- }
- });
- Ext.define("Gnt.model.WeekAvailability", {
- extend : "Sch.model.Range",
- customizableFields : [{
- name : "Availability"
- }],
- availabilityField : "Availability",
- set : function(b, a) {
- if (b === this.nameField) {
- Ext.Array.each(this.getAvailability(), function(c) {
- c.setName(a)
- })
- }
- this.callParent(arguments)
- },
- getAvailability : function() {
- return this.get(this.availabilityField) || []
- },
- setAvailability : function(b) {
- var a = this.getName();
- Ext.Array.each(b, function(c) {
- c.setName(a)
- });
- this.set(this.availabilityField, b)
- }
- });
- Ext.define("Gnt.model.CalendarDay", {
- requires : ["Ext.data.Types"],
- extend : "Sch.model.Customizable",
- idProperty : "Id",
- customizableFields : [{
- name : "Date",
- type : "date",
- dateFormat : "c",
- convert : function(b, a) {
- if (!b) {
- return
- }
- var c = Ext.data.Types.DATE.convert.call(this, b);
- if (c) {
- Ext.Date.clearTime(c)
- }
- if (a.data[a.idProperty] == null) {
- a.data[a.idProperty] = c - 0
- }
- return c
- }
- }, {
- name : "Id"
- }, {
- name : "IsWorkingDay",
- type : "boolean",
- defaultValue : false
- }, {
- name : "Cls",
- defaultValue : "gnt-holiday"
- }, "Name", {
- name : "Availability",
- convert : function(b, a) {
- if (b) {
- return Ext.typeOf(b) === "string" ? [b] : b
- } else {
- return []
- }
- }
- }],
- availabilityCache : null,
- dateField : "Date",
- isWorkingDayField : "IsWorkingDay",
- clsField : "Cls",
- nameField : "Name",
- availabilityField : "Availability",
- setDate : function(b) {
- var a = Ext.Date.clearTime(b, true);
- this.data[this.idProperty] = a - 0;
- this.set(this.dateField, a)
- },
- clearDate : function() {
- this.data[this.idProperty] = null
- },
- getAvailability : function(b) {
- var c = this;
- if (b) {
- return this.get(this.availabilityField)
- }
- if (this.availabilityCache) {
- return this.availabilityCache
- }
- var a = [];
- Ext.Array.each(this.get(this.availabilityField), function(d) {
- a.push(Ext.typeOf(d) === "string" ? c
- .parseInterval(d) : d)
- });
- this.verifyAvailability(a);
- return this.availabilityCache = a
- },
- setAvailability : function(a) {
- this.availabilityCache = null;
- this.set(this.availabilityField, this.stringifyIntervals(a));
- this.getAvailability()
- },
- verifyAvailability : function(b) {
- b.sort(function(f, e) {
- return f.startTime - e.startTime
- });
- Ext.Array.each(b, function(e) {
- if (e.startTime > e.endTime) {
- throw "Start time is greater than end time"
- }
- });
- for (var a = 1; a < b.length; a++) {
- var c = b[a - 1];
- var d = b[a];
- if (c.endTime > d.startTime) {
- throw "Availability intervals should not intersect"
- }
- }
- },
- prependZero : function(a) {
- return a < 10 ? "0" + a : a
- },
- stringifyInterval : function(b) {
- var c = b.startTime;
- var a = b.endTime;
- return this.prependZero(c.getHours()) + ":"
- + this.prependZero(c.getMinutes()) + "-"
- + this.prependZero(a.getHours()) + ":"
- + this.prependZero(a.getMinutes())
- },
- stringifyIntervals : function(b) {
- var c = this;
- var a = [];
- Ext.Array.each(b, function(d) {
- if (Ext.typeOf(d) === "string") {
- a.push(d)
- } else {
- a.push(c.stringifyInterval(d))
- }
- });
- return a
- },
- parseInterval : function(b) {
- var a = /(\d\d):(\d\d)-(\d\d):(\d\d)/.exec(b);
- if (!a) {
- throw "Invalid format for availability string: " + b
- + ". It should have exact format: hh:mm-hh:mm"
- }
- return {
- startTime : new Date(0, 0, 0, a[1], a[2]),
- endTime : new Date(0, 0, 0, a[3], a[4])
- }
- },
- getTotalHours : function() {
- return this.getTotalMS() / 1000 / 60 / 60
- },
- getTotalMS : function() {
- var a = 0;
- Ext.Array.each(this.getAvailability(), function(b) {
- a += b.endTime - b.startTime
- });
- return a
- },
- addAvailabilityInterval : function(d, b) {
- var a;
- if (d instanceof Date) {
- a = {
- startTime : d,
- endTime : b
- }
- } else {
- a = this.parseInterval(d + (b ? "-" + b : ""))
- }
- var c = this.getAvailability().concat(a);
- this.verifyAvailability(c);
- this.setAvailability(c)
- },
- removeAvailbilityInterval : function(a) {
- var b = this.getAvailability();
- b.splice(a, 1);
- this.setAvailability(b)
- },
- getAvailabilityIntervalsFor : function(d) {
- d = typeof d == "number" ? new Date(d) : d;
- var c = d.getFullYear();
- var e = d.getMonth();
- var b = d.getDate();
- var a = [];
- Ext.Array.each(this.getAvailability(), function(f) {
- var g = f.endTime.getDate();
- a.push({
- startDate : new Date(c, e, b,
- f.startTime.getHours(),
- f.startTime.getMinutes()),
- endDate : new Date(c, e, b
- + (g == 1 ? 1 : 0),
- f.endTime.getHours(), f.endTime
- .getMinutes())
- })
- });
- return a
- },
- getAvailabilityStartFor : function(b) {
- var a = this.getAvailabilityIntervalsFor(b);
- if (!a.length) {
- return null
- }
- return a[0].startDate
- },
- getAvailabilityEndFor : function(b) {
- var a = this.getAvailabilityIntervalsFor(b);
- if (!a.length) {
- return null
- }
- return a[a.length - 1].endDate
- }
- });
- Ext.define("Gnt.model.Assignment", {
- extend : "Sch.model.Customizable",
- idProperty : "Id",
- customizableFields : [{
- name : "Id"
- }, {
- name : "ResourceId"
- }, {
- name : "TaskId"
- }, {
- name : "Units",
- type : "float",
- defaultValue : 100
- }],
- resourceIdField : "ResourceId",
- taskIdField : "TaskId",
- unitsField : "Units",
- isPersistable : function() {
- var a = this.getTask(), b = this.getResource();
- return a && !a.phantom && b && !b.phantom
- },
- getUnits : function() {
- return Math.max(0, this.get(this.unitsField))
- },
- setUnits : function(a) {
- if (a < 0) {
- throw "`Units` value for an assignment can't be less than 0"
- }
- this.set(this.unitsField, a)
- },
- getResourceName : function() {
- var a = this.stores[0].getResourceStore().getById(this.getResourceId());
- if (a) {
- return a.getName()
- }
- return ""
- },
- getTask : function(a) {
- return (a || this.stores[0].getTaskStore()).getById(this.getTaskId())
- },
- getResource : function() {
- return this.stores[0].getResourceStore().getByInternalId(this
- .getResourceId())
- },
- getInternalId : function() {
- return this.getId() || this.internalId
- },
- getEffort : function(b) {
- var a = this.getTask();
- var c = 0;
- a.forEachAvailabilityIntervalWithResources({
- startDate : a.getStartDate(),
- endDate : a.getEndDate(),
- resources : [this.getResource()]
- }, function(g, f, e) {
- var h;
- for (var d in e) {
- h = e[d].units
- }
- c += (f - g) * h / 100
- });
- return a.getProjectCalendar().convertMSDurationToUnit(c,
- b || a.getEffortUnit())
- }
- });
- Ext.define("Gnt.model.Dependency", {
- extend : "Sch.model.Customizable",
- inheritableStatics : {
- Type : {
- StartToStart : 0,
- StartToEnd : 1,
- EndToStart : 2,
- EndToEnd : 3
- }
- },
- idProperty : "Id",
- customizableFields : [{
- name : "Id"
- }, {
- name : "From"
- }, {
- name : "To"
- }, {
- name : "Type",
- type : "int",
- defaultValue : 2
- }, {
- name : "Lag",
- type : "number",
- defaultValue : 0
- }, {
- name : "LagUnit",
- type : "string",
- defaultValue : "d",
- convert : function(a) {
- return a || "d"
- }
- }, {
- name : "Cls"
- }],
- fromField : "From",
- toField : "To",
- typeField : "Type",
- lagField : "Lag",
- lagUnitField : "LagUnit",
- clsField : "Cls",
- fromTask : null,
- toTask : null,
- constructor : function(a) {
- this.callParent(arguments);
- if (a) {
- if (a.fromTask) {
- if (a.fromTask instanceof Gnt.model.Task) {
- this.setSourceTask(a.fromTask)
- } else {
- this.setSourceId(a.fromTask)
- }
- }
- if (a.toTask) {
- if (a.toTask instanceof Gnt.model.Task) {
- this.setTargetTask(a.toTask)
- } else {
- this.setTargetId(a.toTask)
- }
- }
- if (Ext.isDefined(a.type)) {
- this.setType(a.type)
- }
- if (Ext.isDefined(a.lag)) {
- this.setLag(a.lag)
- }
- if (Ext.isDefined(a.lagUnit)) {
- this.setLagUnit(a.lagUnit)
- }
- }
- },
- getTaskStore : function() {
- return this.stores[0].taskStore
- },
- getSourceTask : function(a) {
- return (a || this.getTaskStore()).getById(this.getSourceId())
- },
- setSourceTask : function(a) {
- this.setSourceId(a.getId() || a.internalId)
- },
- getTargetTask : function(a) {
- return (a || this.getTaskStore()).getById(this.getTargetId())
- },
- setTargetTask : function(a) {
- this.setTargetId(a.getId() || a.internalId)
- },
- getSourceId : function() {
- return this.get(this.fromField)
- },
- setSourceId : function(a) {
- this.set(this.fromField, a)
- },
- getTargetId : function() {
- return this.get(this.toField)
- },
- setTargetId : function(a) {
- this.set(this.toField, a)
- },
- getLagUnit : function() {
- return this.get(this.lagUnitField) || "d"
- },
- isPersistable : function() {
- var a = this.getSourceTask(), b = this.getTargetTask();
- return a && !a.phantom && b && !b.phantom
- },
- isValid : function(b) {
- var c = this.callParent(arguments), d = this.getSourceId(), a = this
- .getTargetId();
- if (c) {
- c = Ext.isNumber(this.getType()) && !Ext.isEmpty(d)
- && !Ext.isEmpty(a)
- }
- if (c && b !== false && this.stores[0]) {
- c = this.stores[0].isValidDependency(d, a, true)
- }
- return c
- }
- });
- Ext.define("Gnt.model.Resource", {
- extend : "Sch.model.Resource",
- customizableFields : ["CalendarId"],
- calendarIdField : "CalendarId",
- getTaskStore : function() {
- return this.stores[0].getTaskStore()
- },
- getEventStore : function() {
- return this.getTaskStore()
- },
- getEvents : function() {
- return this.getTasks()
- },
- getTasks : function() {
- var a = [];
- this.forEachAssignment(function(b) {
- var c = b.getTask();
- if (c) {
- a.push(c)
- }
- });
- return a
- },
- getCalendar : function(a) {
- return a ? this.getOwnCalendar() : this.getOwnCalendar()
- || this.getProjectCalendar()
- },
- getOwnCalendar : function() {
- var a = this.getCalendarId();
- return a ? Gnt.data.Calendar.getCalendar(a) : null
- },
- getProjectCalendar : function() {
- return this.stores[0].getTaskStore().getCalendar()
- },
- setCalendar : function(a) {
- },
- getInternalId : function() {
- return this.getId() || this.internalId
- },
- assignTo : function(a, c) {
- var b = a instanceof Gnt.model.Task ? a : this.getTaskStore()
- .getById(a);
- return b.assign(this, c)
- },
- unassignFrom : function() {
- return this.unAssignFrom.apply(this, arguments)
- },
- unAssignFrom : function(a) {
- var b = a instanceof Gnt.model.Task ? a : this.getTaskStore()
- .getById(a);
- b.unAssign(this)
- },
- forEachAssignment : function(b, a) {
- a = a || this;
- var c = this.getInternalId();
- this.getTaskStore().getAssignmentStore().each(function(d) {
- if (d.getResourceId() == c) {
- return b.call(a, d)
- }
- })
- },
- collectAvailabilityIntervalPoints : function(e, f, b, h, c) {
- for (var d = 0; d < e.length; d++) {
- var a = e[d];
- var g = a.startDate - 0;
- var i = a.endDate - 0;
- if (!h[g]) {
- h[g] = [];
- c.push(g)
- }
- h[g].push(f(g));
- if (!h[i]) {
- h[i] = [];
- c.push(i)
- }
- h[i].push(b(i))
- }
- },
- forEachAvailabilityIntervalWithTasks : function(d, f, a) {
- a = a || this;
- var c = d.startDate;
- var t = d.endDate;
- if (!c || !t) {
- throw "Both `startDate` and `endDate` are required for `forEachAvailabilityIntervalWithTasks`"
- }
- var g = new Date(c);
- var u = d.includeAllIntervals;
- var p = this.getCalendar();
- var l = [];
- var n = [];
- var b = [];
- this.forEachAssignment(function(k) {
- var i = k.getTask();
- if (i.getStartDate() > t || i.getEndDate() < c) {
- return
- }
- n.push(i);
- b.push(i.getCalendar());
- l.push(k)
- });
- if (!n.length) {
- return
- }
- var e = Sch.util.Date;
- var y = [c - 0, t - 0];
- var j = {};
- j[c - 0] = [{
- type : "00-intervalStart"
- }];
- j[t - 0] = [{
- type : "00-intervalEnd"
- }];
- var s;
- while (g < t) {
- this.collectAvailabilityIntervalPoints(p
- .getAvailabilityIntervalsFor(g), function() {
- return {
- type : "00-resourceAvailabilityStart"
- }
- }, function() {
- return {
- type : "01-resourceAvailabilityEnd"
- }
- }, j, y);
- for (s = 0; s < b.length; s++) {
- this.collectAvailabilityIntervalPoints(b[s]
- .getAvailabilityIntervalsFor(g), function() {
- return {
- type : "02-taskAvailabilityStart",
- assignment : l[s],
- taskId : n[s].getInternalId(),
- units : l[s].getUnits()
- }
- }, function() {
- return {
- type : "03-taskAvailabilityEnd",
- taskId : n[s].getInternalId()
- }
- }, j, y)
- }
- g = e.getStartOfNextDay(g)
- }
- y.sort();
- var v = false;
- var w = {};
- var m = 0;
- for (s = 0; s < y.length - 1; s++) {
- var r = j[y[s]];
- r.sort(function(k, i) {
- return k.type < i.type
- });
- for (var q = 0; q < r.length; q++) {
- var o = r[q];
- if (o.type == "00-resourceAvailabilityStart") {
- v = true
- }
- if (o.type == "01-resourceAvailabilityEnd") {
- v = false
- }
- if (o.type == "02-taskAvailabilityStart") {
- w[o.taskId] = o;
- m++
- }
- if (o.type == "03-taskAvailabilityEnd") {
- delete w[o.taskId];
- m--
- }
- }
- if (u || v && m) {
- var x = y[s];
- var h = y[s + 1];
- if (x > t || h < c) {
- continue
- }
- if (x < c) {
- x = c - 0
- }
- if (h > t) {
- h = t - 0
- }
- if (f.call(a, x, h, w) === false) {
- return false
- }
- }
- }
- },
- getAllocationInfo : function(a) {
- var b = [];
- this.forEachAvailabilityIntervalWithTasks(a, function(h, g, f) {
- var e = 0;
- var c = [];
- for (var d in f) {
- e += f[d].units;
- c.push(f[d].assignment)
- }
- b.push({
- startDate : new Date(h),
- endDate : new Date(g),
- totalAllocation : e,
- assignments : c
- })
- });
- return b
- }
- });
- Ext.define("Gnt.model.task.More", {
- indent : function() {
- var a = this.previousSibling;
- if (a) {
- this.isMove = true;
- a.appendChild(this);
- delete this.isMove;
- a.set("leaf", false);
- a.expand()
- }
- },
- outdent : function() {
- var a = this.parentNode;
- if (a && !a.isRoot()) {
- if (this.convertEmptyParentToLeaf) {
- a.set("leaf", a.childNodes.length === 1)
- }
- this.isMove = true;
- if (a.nextSibling) {
- a.parentNode.insertBefore(this, a.nextSibling)
- } else {
- a.parentNode.appendChild(this)
- }
- delete this.isMove
- }
- },
- getAllDependencies : function(a) {
- a = a || this.getDependencyStore();
- return a.getDependenciesForTask(this)
- },
- hasIncomingDependencies : function(a) {
- var c = this.getId() || this.internalId;
- a = a || this.getDependencyStore();
- var b = a.findBy(function(d) {
- return d.getTargetId() == c
- });
- return b >= 0
- },
- getIncomingDependencies : function(a) {
- a = a || this.getDependencyStore();
- return a.getIncomingDependenciesForTask(this)
- },
- getOutgoingDependencies : function(a) {
- a = a || this.getDependencyStore();
- return a.getOutgoingDependenciesForTask(this)
- },
- constrain : function(c) {
- if (this.isManuallyScheduled()) {
- return false
- }
- var e = false;
- c = c || this.getTaskStore();
- var b = this.getConstrainContext(c);
- if (b) {
- var a = b.startDate;
- var d = b.endDate;
- if (a && a - this.getStartDate() !== 0) {
- this.setStartDate(a, true, c.skipWeekendsDuringDragDrop);
- e = true
- } else {
- if (d && d - this.getEndDate() !== 0) {
- this.setEndDate(d, true, c.skipWeekendsDuringDragDrop);
- e = true
- }
- }
- }
- return e
- },
- getConstrainContext : function(f) {
- var g = this.getIncomingDependencies();
- if (!g.length) {
- return null
- }
- var h = f || this.getTaskStore(), a = Gnt.model.Dependency.Type, c = new Date(0), b = new Date(0), i = Ext.Date, e = this
- .getProjectCalendar(), d;
- Ext.each(g, function(l) {
- var k = l.getSourceTask();
- if (k) {
- var o = l.getLag() || 0, m = l.getLagUnit(), n = k
- .getStartDate(), j = k.getEndDate();
- switch (l.getType()) {
- case a.StartToEnd :
- n = e.skipWorkingTime(n, o, m);
- if (b < n) {
- b = n;
- d = k
- }
- break;
- case a.StartToStart :
- n = e.skipWorkingTime(n, o, m);
- if (c < n) {
- c = n;
- d = k
- }
- break;
- case a.EndToStart :
- j = e.skipWorkingTime(j, o, m);
- if (c < j) {
- c = j;
- d = k
- }
- break;
- case a.EndToEnd :
- j = e.skipWorkingTime(j, o, m);
- if (b < j) {
- b = j;
- d = k
- }
- break;
- default :
- throw "Invalid dependency type: " + l.getType()
- }
- }
- });
- return {
- startDate : c > 0 ? c : null,
- endDate : b > 0 ? b : null,
- constrainingTask : d
- }
- },
- getCriticalPaths : function() {
- var b = [this], a = this.getConstrainContext();
- while (a) {
- b.push(a.constrainingTask);
- a = a.constrainingTask.getConstrainContext()
- }
- return b
- },
- cascadeChanges : function(a, b, c) {
- a = a || this.getTaskStore();
- var d;
- if (this.isLeaf()) {
- d = this.constrain(a);
- if (d) {
- this.recalculateParents();
- b.nbrAffected++
- }
- }
- if (d) {
- Ext.each(this.getOutgoingDependencies(), function(e) {
- var f = e.getTargetTask();
- if (f && !f.isManuallyScheduled()) {
- f.cascadeChanges(a, b, e)
- }
- })
- }
- },
- addSubtask : function(a) {
- this.set("leaf", false);
- this.appendChild(a);
- this.expand();
- return a
- },
- addSuccessor : function(b) {
- var c = this.rec, e = this.getTaskStore(), d = this
- .getDependencyStore();
- b = b || new this.self();
- b.calendar = b.calendar || this.getCalendar();
- b.taskStore = e;
- b.setStartDate(this.getEndDate(), true, e.skipWeekendsDuringDragDrop);
- b.setDuration(1, Sch.util.Date.DAY);
- this.addTaskBelow(b);
- var a = new d.model({
- fromTask : this,
- toTask : b,
- type : d.model.Type.EndToStart
- });
- d.add(a);
- return b
- },
- addMilestone : function(c) {
- var b = this.getTaskStore();
- c = c || new this.self();
- var a = this.getEndDate();
- if (a) {
- c.calendar = c.calendar || this.getCalendar();
- c.setStartEndDate(a, a, b.skipWeekendsDuringDragDrop)
- }
- return this.addTaskBelow(c)
- },
- addPredecessor : function(c) {
- var b = this.getDependencyStore();
- c = c || new this.self();
- c.calendar = c.calendar || this.getCalendar();
- c.beginEdit();
- c.set(this.startDateField, c.calculateStartDate(this.getStartDate(), 1,
- Sch.util.Date.DAY));
- c.set(this.endDateField, this.getStartDate());
- c.set(this.durationField, 1);
- c.set(this.durationUnitField, Sch.util.Date.DAY);
- c.endEdit();
- this.addTaskAbove(c);
- var a = new b.model({
- fromTask : c,
- toTask : this,
- type : b.model.Type.EndToStart
- });
- b.add(a);
- return c
- },
- getSuccessors : function() {
- var h = this.getId() || this.internalId;
- var e = e || this.getDependencyStore();
- var c = this.getTaskStore(), g = [];
- for (var f = 0, a = e.getCount(); f < a; f++) {
- var d = e.getAt(f);
- if (d.getSourceId() == h) {
- var b = d.getTargetTask();
- if (b) {
- g.push(b)
- }
- }
- }
- return g
- },
- getPredecessors : function() {
- var g = this.getId() || this.internalId;
- var d = d || this.getDependencyStore();
- var b = this.getTaskStore(), f = [];
- for (var e = 0, a = d.getCount(); e < a; e++) {
- var c = d.getAt(e);
- if (c.getTargetId() == g) {
- f.push(c.getSourceTask())
- }
- }
- return f
- },
- addTaskAbove : function(a) {
- a = a || new this.self();
- return this.parentNode.insertBefore(a, this)
- },
- addTaskBelow : function(a) {
- a = a || new this.self();
- if (this.nextSibling) {
- return this.parentNode.insertBefore(a, this.nextSibling)
- } else {
- return this.parentNode.appendChild(a)
- }
- },
- isAbove : function(a) {
- var b = this, c = Math.min(b.data.depth, a.data.depth);
- while (b.data.depth > c) {
- b = b.parentNode
- }
- while (a.data.depth > c) {
- a = a.parentNode
- }
- while (a.parentNode !== b.parentNode) {
- a = a.parentNode;
- b = b.parentNode
- }
- return a.data.index > b.data.index
- },
- cascadeChildren : function(a, c, b) {
- this.cascadeBy(function(d) {
- if (d !== a) {
- return c.call(b || d, d)
- }
- })
- }
- });
- Ext.define("Gnt.model.Task", {
- extend : "Sch.model.Range",
- requires : ["Sch.util.Date", "Ext.data.NodeInterface"],
- mixins : ["Gnt.model.task.More"],
- idProperty : "Id",
- customizableFields : [{
- name : "Id"
- }, {
- name : "Duration",
- type : "number",
- useNull : true
- }, {
- name : "Effort",
- type : "number",
- useNull : true
- }, {
- name : "EffortUnit",
- type : "string",
- defaultValue : "h"
- }, {
- name : "CalendarId",
- type : "string"
- }, {
- name : "DurationUnit",
- type : "string",
- defaultValue : "d",
- convert : function(a) {
- return a || "d"
- }
- }, {
- name : "PercentDone",
- type : "int",
- defaultValue : 0
- }, {
- name : "ManuallyScheduled",
- type : "boolean",
- defaultValue : false
- }, {
- name : "SchedulingMode",
- type : "string",
- defaultValue : "Normal"
- }, {
- name : "BaselineStartDate",
- type : "date",
- dateFormat : "c"
- }, {
- name : "BaselineEndDate",
- type : "date",
- dateFormat : "c"
- }, {
- name : "BaselinePercentDone",
- type : "int",
- defaultValue : 0
- }, {
- name : "Draggable",
- type : "boolean",
- persist : false,
- defaultValue : true
- }, {
- name : "Resizable",
- persist : false
- }, {
- name : "PhantomId",
- type : "string"
- }, {
- name : "PhantomParentId",
- type : "string"
- }],
- draggableField : "Draggable",
- resizableField : "Resizable",
- nameField : "Name",
- durationField : "Duration",
- durationUnitField : "DurationUnit",
- effortField : "Effort",
- effortUnitField : "EffortUnit",
- percentDoneField : "PercentDone",
- manuallyScheduledField : "ManuallyScheduled",
- schedulingModeField : "SchedulingMode",
- calendarIdField : "CalendarId",
- baselineStartDateField : "BaselineStartDate",
- baselineEndDateField : "BaselineEndDate",
- baselinePercentDoneField : "BaselinePercentDone",
- calendar : null,
- dependencyStore : null,
- taskStore : null,
- phantomIdField : "PhantomId",
- phantomParentIdField : "PhantomParentId",
- normalized : false,
- recognizedSchedulingModes : ["Normal", "Manual", "FixedDuration",
- "EffortDriven", "DynamicAssignment"],
- convertEmptyParentToLeaf : true,
- constructor : function() {
- this.getModifiedFieldNames = function() {
- if (this.__isFilling__) {
- return []
- }
- delete this.getModifiedFieldNames;
- return this.getModifiedFieldNames.apply(this, arguments)
- };
- this.callParent(arguments);
- if (this.phantom) {
- this.data[this.phantomIdField] = this.internalId
- }
- },
- normalize : function() {
- var c = this.getDuration(), g = this.getDurationUnit(), b = this
- .getStartDate(), f = this.getEndDate(), e = this
- .getSchedulingMode(), d = this.data;
- if (f && this.inclusiveEndDate) {
- var i = this.fields.getByKey(this.endDateField).dateFormat;
- var a = (i && !Ext.Date.formatContainsHourInfo(i))
- || (f.getHours() === 0 && f.getMinutes() === 0
- && f.getSeconds() === 0 && f.getMilliseconds() === 0);
- if (a) {
- if (Ext.isNumber(c)) {
- f = d[this.endDateField] = this.calculateEndDate(b, c, g)
- } else {
- f = d[this.endDateField] = Ext.Date.add(f, Ext.Date.DAY, 1)
- }
- }
- }
- if (c == null && b && f) {
- d[this.durationField] = this.calculateDuration(b, f, g)
- }
- if ((e == "Normal" || this.isManuallyScheduled()) && f == null && b
- && Ext.isNumber(c)) {
- d[this.endDateField] = this.calculateEndDate(b, c, g)
- }
- if (e == "EffortDriven" || e == "FixedDuration") {
- var j = this.get(this.effortField), h = this.getEffortUnit();
- if (j == null && b && f) {
- d[this.effortField] = this.calculateEffort(b, f, h)
- }
- if (f == null && b && j) {
- d[this.endDateField] = this.calculateEffortDrivenEndDate(b, j,
- h);
- if (c == null) {
- d[this.durationField] = this.calculateDuration(b,
- d[this.endDateField], g)
- }
- }
- }
- this.normalized = true
- },
- normalizeEffort : function() {
- var c = this.childNodes;
- var b = 0;
- for (var a = 0; a < c.length; a++) {
- var d = c[a];
- if (!d.isLeaf()) {
- d.normalizeEffort()
- }
- b += d.getEffort("MILLI")
- }
- if (this.getEffort("MILLI") != b) {
- this.data[this.effortField] = this.getProjectCalendar()
- .convertMSDurationToUnit(b, this.getEffortUnit())
- }
- },
- getInternalId : function() {
- return this.getId() || this.internalId
- },
- getCalendar : function(a) {
- return a ? this.getOwnCalendar() : this.getOwnCalendar()
- || this.getProjectCalendar()
- },
- getOwnCalendar : function() {
- var a = this.get(this.calendarIdField);
- return a ? Gnt.data.Calendar.getCalendar(a) : this.calendar
- },
- getProjectCalendar : function() {
- var a = this.stores[0];
- var b = a && a.getCalendar && a.getCalendar() || this.parentNode
- && this.parentNode.getProjectCalendar() || this.isRoot()
- && this.calendar;
- if (!b) {
- Ext.Error
- .raise("Can't find a project calendar in `getProjectCalendar`")
- }
- return b
- },
- setCalendar : function(a) {
- this.calendar = a
- },
- getDependencyStore : function() {
- var a = this.dependencyStore || this.getTaskStore().dependencyStore;
- if (!a) {
- Ext.Error
- .raise("Can't find a dependencyStore in `getDependencyStore`")
- }
- return a
- },
- getResourceStore : function() {
- return this.getTaskStore().getResourceStore()
- },
- getAssignmentStore : function() {
- return this.getTaskStore().getAssignmentStore()
- },
- getTaskStore : function(b) {
- if (this.taskStore) {
- return this.taskStore
- }
- var a = this.stores[0] && this.stores[0].taskStore || this.parentNode
- && this.parentNode.getTaskStore(b);
- if (!a && !b) {
- Ext.Error.raise("Can't find a taskStore in `getTaskStore`")
- }
- return this.taskStore = a
- },
- isManuallyScheduled : function() {
- return this.get(this.schedulingModeField) == "Manual"
- || this.get(this.manuallyScheduledField)
- },
- setManuallyScheduled : function(a) {
- if (a) {
- this.set(this.schedulingModeField, "Manual")
- } else {
- if (this.get(this.schedulingModeField) == "Manual") {
- this.set(this.schedulingModeField, "Normal")
- }
- }
- return this.set(this.manuallyScheduledField, a)
- },
- setSchedulingMode : function(a) {
- if (!Ext.Array.contains(this.recognizedSchedulingModes, a)) {
- throw "Unrecognized scheduling mode: " + a
- }
- this.beginEdit();
- this.set(this.schedulingModeField, a);
- if (a === "FixedDuration") {
- this.updateEffortBasedOnDuration()
- }
- if (a === "EffortDriven") {
- this.updateDurationBasedOnEffort()
- }
- this.endEdit()
- },
- skipNonWorkingTime : function(b, c) {
- var a = false;
- this.forEachAvailabilityIntervalWithResources(c ? {
- startDate : b
- } : {
- endDate : b,
- isForward : false
- }, function(f, e, d) {
- b = c ? f : e;
- a = true;
- return false
- });
- return a ? new Date(b) : this.getCalendar().skipNonWorkingTime(b, c)
- },
- setStartDate : function(a, f, e) {
- this.beginEdit();
- if (!a) {
- this.set(this.durationField, null);
- this.set(this.startDateField, null)
- } else {
- var d = this.getCalendar();
- if (e && !this.isManuallyScheduled()) {
- if (!this.isMilestone() || d.isHoliday(a - 1)) {
- a = this.skipNonWorkingTime(a, true)
- }
- }
- var b = this.getSchedulingMode();
- this.set(this.startDateField, a);
- if (f !== false) {
- if (b == "EffortDriven") {
- this.set(this.endDateField, this
- .calculateEffortDrivenEndDate(a, this
- .getEffort()))
- } else {
- var c = this.getDuration();
- if (Ext.isNumber(c)) {
- this.set(this.endDateField, this.calculateEndDate(a, c,
- this.getDurationUnit()))
- }
- }
- } else {
- if (this.getEndDate()) {
- this.set(this.durationField, this.calculateDuration(a, this
- .getEndDate(), this
- .getDurationUnit()))
- }
- }
- }
- this.onPotentialEffortChange();
- this.endEdit()
- },
- setEndDate : function(a, e, d) {
- this.beginEdit();
- if (!a) {
- this.set(this.durationField, null);
- this.set(this.endDateField, null)
- } else {
- var c = this.getCalendar();
- if (d && !this.isManuallyScheduled()) {
- a = this.skipNonWorkingTime(a, false)
- }
- if (e !== false) {
- var b = this.getDuration();
- if (Ext.isNumber(b)) {
- this.set(this.startDateField, this.calculateStartDate(a, b,
- this.getDurationUnit()));
- this.set(this.endDateField, a)
- } else {
- this.set(this.endDateField, a)
- }
- } else {
- this.set(this.endDateField, a);
- if (this.getStartDate()) {
- this.set(this.durationField, this.calculateDuration(this
- .getStartDate(), a, this
- .getDurationUnit()))
- }
- }
- }
- this.onPotentialEffortChange();
- this.endEdit()
- },
- setStartEndDate : function(a, b, c) {
- this.beginEdit();
- if (c && !this.isManuallyScheduled()) {
- a = a && this.skipNonWorkingTime(a, true);
- b = b && this.skipNonWorkingTime(b, false)
- }
- this.set(this.startDateField, a);
- this.set(this.endDateField, b);
- this.set(this.durationField, this.calculateDuration(a, b, this
- .getDurationUnit()));
- this.onPotentialEffortChange();
- this.endEdit()
- },
- getDuration : function(a) {
- if (!a) {
- return this.get(this.durationField)
- }
- var b = this.getProjectCalendar(), c = b.convertDurationToMs(this
- .get(this.durationField), this
- .get(this.durationUnitField));
- return b.convertMSDurationToUnit(c, a)
- },
- getEffort : function(a) {
- var b = this.get(this.effortField) || 0;
- if (!a) {
- return b
- }
- var c = this.getProjectCalendar(), d = c.convertDurationToMs(b, this
- .getEffortUnit());
- return c.convertMSDurationToUnit(d, a)
- },
- setEffort : function(b, a) {
- a = a || this.get(this.effortUnitField);
- this.beginEdit();
- this.set(this.effortField, b);
- this.set(this.effortUnitField, a);
- if (this.getSchedulingMode() === "EffortDriven") {
- this.updateDurationBasedOnEffort()
- }
- if (this.getSchedulingMode() === "DynamicAssignment") {
- this.updateAssignments()
- }
- this.endEdit()
- },
- getCalendarDuration : function(a) {
- return this.getProjectCalendar().convertMSDurationToUnit(
- this.getEndDate() - this.getStartDate(),
- a || this.get(this.durationUnitField))
- },
- setDuration : function(d, c) {
- c = c || this.get(this.durationUnitField);
- this.beginEdit();
- if (Ext.isNumber(d) && !this.getStartDate()) {
- var a = new Date();
- Ext.Date.clearTime(a);
- this.setStartDate(a)
- }
- var b = null;
- if (Ext.isNumber(d)) {
- b = this.calculateEndDate(this.getStartDate(), d, c)
- }
- this.set(this.endDateField, b);
- this.set(this.durationField, d);
- this.set(this.durationUnitField, c);
- this.onPotentialEffortChange();
- this.endEdit()
- },
- calculateStartDate : function(e, d, c) {
- c = c || this.getDurationUnit();
- if (this.isManuallyScheduled()) {
- return Sch.util.Date.add(a, c, -d)
- } else {
- if (this.getTaskStore(true) && this.hasAssignments()) {
- var b = this.getProjectCalendar().convertDurationToMs(d,
- c || this.getDurationUnit());
- var a;
- this.forEachAvailabilityIntervalWithResources({
- endDate : e,
- isForward : false
- }, function(i, h, g) {
- var f = h - i;
- if (f >= b) {
- a = new Date(h - b);
- return false
- } else {
- b -= f
- }
- });
- return a
- } else {
- return this.getCalendar().calculateStartDate(e, d, c)
- }
- }
- },
- calculateEndDate : function(a, f, d) {
- d = d || this.getDurationUnit();
- if (this.isManuallyScheduled()) {
- return Sch.util.Date.add(a, d, f)
- } else {
- var c = this.getSchedulingMode();
- if (this.getTaskStore(true) && this.hasAssignments()
- && c != "FixedDuration" && c != "DynamicAssignment"
- && c != "EffortDriven") {
- var b = this.getProjectCalendar().convertDurationToMs(f,
- d || this.getDurationUnit());
- var e;
- this.forEachAvailabilityIntervalWithResources({
- startDate : a
- }, function(j, i, h) {
- var g = i - j;
- if (g >= b) {
- e = new Date(j + b);
- return false
- } else {
- b -= g
- }
- });
- return e
- } else {
- return this.getCalendar().calculateEndDate(a, f, d)
- }
- }
- },
- calculateDuration : function(a, c, b) {
- b = b || this.getDurationUnit();
- if (!a || !c) {
- return 0
- }
- if (this.isManuallyScheduled()) {
- return this.getProjectCalendar().convertMSDurationToUnit(c - a, b)
- } else {
- if (this.getTaskStore(true) && this.hasAssignments()) {
- var d = 0;
- this.forEachAvailabilityIntervalWithResources({
- startDate : a,
- endDate : c
- }, function(g, f, e) {
- d += f - g
- });
- return this.getProjectCalendar().convertMSDurationToUnit(d, b)
- } else {
- return this.getCalendar().calculateDuration(a, c, b)
- }
- }
- },
- forEachAvailabilityIntervalWithResources : function(f, h, a) {
- a = a || this;
- var C = this;
- var d = f.startDate;
- var z = f.endDate;
- var p = f.isForward !== false;
- if (p ? !d : !z) {
- throw new Error("At least `startDate` or `endDate` is required, depending from the `isForward` option")
- }
- var j = new Date(p ? d : z);
- var b = f.includeEmptyIntervals;
- var c = this.getOwnCalendar();
- var G = Boolean(c);
- var E = this.getProjectCalendar();
- var A, v, r;
- if (f.resources) {
- A = f.resources;
- r = [];
- v = [];
- Ext.each(A, function(i) {
- v.push(i.getCalendar());
- r.push(C.getAssignmentFor(i))
- })
- } else {
- r = this.getAssignments();
- if (!r.length) {
- return
- }
- A = [];
- v = [];
- Ext.each(r, function(k) {
- var i = k.getResource();
- A.push(i);
- v.push(i.getCalendar())
- })
- }
- var g = Sch.util.Date;
- var y, u, B, D, n;
- var t = p ? !z : !d;
- while (t || (p ? j < z : j > d)) {
- var q = {};
- var F = [];
- if (G) {
- var l = c.getAvailabilityIntervalsFor(j - (p ? 0 : 1));
- for (u = 0; u < l.length; u++) {
- B = l[u];
- D = B.startDate - 0;
- n = B.endDate - 0;
- if (!q[D]) {
- q[D] = [];
- F.push(D)
- }
- q[D].push({
- type : "00-taskAvailailabilityStart",
- typeBackward : "01-taskAvailailabilityStart"
- });
- F.push(n);
- q[n] = q[n] || [];
- q[n].push({
- type : "01-taskAvailailabilityEnd",
- typeBackward : "00-taskAvailailabilityEnd"
- })
- }
- }
- for (y = 0; y < v.length; y++) {
- var e = v[y].getAvailabilityIntervalsFor(j);
- for (u = 0; u < e.length; u++) {
- B = e[u];
- D = B.startDate - 0;
- n = B.endDate - 0;
- if (!q[D]) {
- q[D] = [];
- F.push(D)
- }
- q[D].push({
- type : "02-resourceAvailailabilityStart",
- typeBackward : "03-resourceAvailailabilityStart",
- assignment : r[y],
- resourceId : A[y].getInternalId(),
- units : r[y].getUnits()
- });
- if (!q[n]) {
- q[n] = [];
- F.push(n)
- }
- q[n].push({
- type : "03-resourceAvailailabilityEnd",
- typeBackward : "02-resourceAvailailabilityEnd",
- assignment : r[y],
- resourceId : A[y].getInternalId(),
- units : r[y].getUnits()
- })
- }
- }
- F.sort();
- var x = false;
- var o = {};
- var m = 0;
- var w, s;
- if (p) {
- for (y = 0; y < F.length; y++) {
- w = q[F[y]];
- w.sort(function(k, i) {
- return k.type < i.type
- });
- for (u = 0; u < w.length; u++) {
- s = w[u];
- if (s.type == "00-taskAvailailabilityStart") {
- x = true
- }
- if (s.type == "01-taskAvailailabilityEnd") {
- x = false
- }
- if (s.type == "02-resourceAvailailabilityStart") {
- o[s.resourceId] = s;
- m++
- }
- if (s.type == "03-resourceAvailailabilityEnd") {
- delete o[s.resourceId];
- m--
- }
- }
- if ((x || !G) && (m || b)) {
- D = F[y];
- n = F[y + 1];
- if (D >= z || n <= d) {
- continue
- }
- if (D < d) {
- D = d - 0
- }
- if (n > z) {
- n = z - 0
- }
- if (h.call(a, D, n, o) === false) {
- return false
- }
- }
- }
- } else {
- for (y = F.length - 1; y >= 0; y--) {
- w = q[F[y]];
- w.sort(function(k, i) {
- return k.typeBackward < i.typeBackward
- });
- for (u = 0; u < w.length; u++) {
- s = w[u];
- if (s.typeBackward == "00-taskAvailailabilityEnd") {
- x = true
- }
- if (s.typeBackward == "01-taskAvailailabilityStart") {
- x = false
- }
- if (s.typeBackward == "02-resourceAvailailabilityEnd") {
- o[s.resourceId] = s;
- m++
- }
- if (s.typeBackward == "03-resourceAvailailabilityStart") {
- delete o[s.resourceId];
- m--
- }
- }
- if ((x || !G) && (m || b)) {
- D = F[y - 1];
- n = F[y];
- if (D > z || n <= d) {
- continue
- }
- if (D < d) {
- D = d - 0
- }
- if (n > z) {
- n = z - 0
- }
- if (h.call(a, D, n, o) === false) {
- return false
- }
- }
- }
- }
- j = p ? g.getStartOfNextDay(j) : g.getEndOfPreviousDay(j)
- }
- },
- calculateEffortDrivenEndDate : function(a, c, b) {
- var e = this.getProjectCalendar().convertDurationToMs(c,
- b || this.getEffortUnit());
- var d = new Date(a);
- this.forEachAvailabilityIntervalWithResources({
- startDate : a
- }, function(l, k, j) {
- var m = 0;
- for (var h in j) {
- m += j[h].units
- }
- var g = k - l;
- var f = m * g / 100;
- if (f >= e) {
- d = new Date(l + e / f * g);
- return false
- } else {
- e -= f
- }
- });
- return d
- },
- recalculateParents : function() {
- var h = new Date(9999, 0, 0), e = new Date(0), m = this.parentNode;
- if (m && m.childNodes.length > 0) {
- var b = 0;
- for (var f = 0, j = m.childNodes.length; f < j; f++) {
- b += m.childNodes[f].getEffort("MILLI")
- }
- if (m.getEffort("MILLI") != b) {
- m.setEffort(this.getProjectCalendar().convertMSDurationToUnit(
- b, m.getEffortUnit()))
- }
- }
- var n, c;
- if (m && !m.isRoot() && m.childNodes.length > 0) {
- if (!m.isManuallyScheduled()) {
- for (var g = 0, d = m.childNodes.length; g < d; g++) {
- var a = m.childNodes[g];
- h = Sch.util.Date.min(h, a.getStartDate() || h);
- e = Sch.util.Date.max(e, a.getEndDate() || e)
- }
- n = h - new Date(9999, 0, 0) !== 0
- && m.getStartDate() - h !== 0;
- c = e - new Date(0) !== 0 && m.getEndDate() - e !== 0;
- if (n && c) {
- m.setStartEndDate(h, e, false)
- } else {
- if (n) {
- m.setStartDate(h, c, false)
- } else {
- if (c) {
- m.setEndDate(e, false, false)
- }
- }
- }
- }
- if (!n && !c) {
- m.recalculateParents()
- }
- }
- },
- isMilestone : function() {
- return this.getDuration() === 0
- },
- isBaselineMilestone : function() {
- var b = this.getBaselineStartDate(), a = this.getBaselineEndDate();
- if (b && a) {
- return a - b === 0
- }
- return false
- },
- afterEdit : function(b) {
- if (this.stores.length > 0 || !this.normalized) {
- this.callParent(arguments)
- } else {
- var a = this.taskStore || this.getTaskStore(true);
- if (a && !a.isFillingRoot) {
- a.afterEdit(this, b)
- }
- this.callParent(arguments)
- }
- },
- afterCommit : function() {
- this.callParent(arguments);
- if (this.stores.length > 0 || !this.normalized) {
- return
- }
- var a = this.taskStore || this.getTaskStore(true);
- if (a && !a.isFillingRoot) {
- a.afterCommit(this)
- }
- },
- afterReject : function() {
- if (this.stores.length > 0) {
- this.callParent(arguments)
- } else {
- var a = this.getTaskStore(true);
- if (a && !a.isFillingRoot) {
- a.afterReject(this)
- }
- this.callParent(arguments)
- }
- },
- getDurationUnit : function() {
- return this.get(this.durationUnitField) || "d"
- },
- getEffortUnit : function() {
- return this.get(this.effortUnitField) || "h"
- },
- getBaselinePercentDone : function() {
- return this.get(this.baselinePercentDoneField) || 0
- },
- isPersistable : function() {
- var a = this.parentNode;
- return !a.phantom
- },
- getResources : function() {
- var b = this.getAssignmentStore(), c = this.getInternalId();
- var a = [];
- if (b) {
- b.each(function(d) {
- if (d.getTaskId() == c) {
- a.push(d.getResource())
- }
- })
- }
- return a
- },
- getAssignments : function() {
- var b = this.getAssignmentStore(), c = this.getInternalId();
- var a = [];
- if (b) {
- b.each(function(d) {
- if (d.getTaskId() == c) {
- a.push(d)
- }
- })
- }
- return a
- },
- hasAssignments : function() {
- var b = this.getAssignmentStore(), c = this.getInternalId();
- var a = false;
- if (b) {
- b.each(function(d) {
- if (d.getTaskId() == c) {
- a = true;
- return false
- }
- })
- }
- return a
- },
- getAssignmentFor : function(b) {
- var c = this.getAssignmentStore(), e = this.getInternalId(), d = b instanceof Gnt.model.Resource
- ? b.getInternalId()
- : b;
- var a;
- if (c) {
- c.each(function(f) {
- if (f.getTaskId() == e && f.getResourceId() == d) {
- a = f;
- return false
- }
- })
- }
- return a || null
- },
- unassign : function() {
- return this.unAssign.apply(this, arguments)
- },
- unAssign : function(c) {
- var d = this.getAssignmentStore();
- var b = this.getInternalId();
- var e = c instanceof Gnt.model.Resource ? c.getInternalId() : c;
- var a = d.findBy(function(f) {
- return f.getResourceId() == e && f.getTaskId() == b
- });
- if (a >= 0) {
- d.removeAt(a)
- }
- },
- assign : function(e, a) {
- var b = this.getTaskStore(), h = this.getInternalId(), f = b
- .getAssignmentStore(), d = b.getResourceStore();
- var g = e instanceof Gnt.model.Resource ? e.getInternalId() : e;
- f.each(function(i) {
- if (i.getTaskId() == h && i.getResourceId() == g) {
- throw "Resource can't be assigned twice to the same task"
- }
- });
- if (e instanceof Gnt.model.Resource && d.indexOf(e) == -1) {
- d.add(e)
- }
- var c = new Gnt.model.Assignment({
- TaskId : h,
- ResourceId : g,
- Units : a
- });
- f.add(c);
- return c
- },
- calculateEffort : function(a, c, b) {
- var d = 0;
- this.forEachAvailabilityIntervalWithResources({
- startDate : a,
- endDate : c
- }, function(h, g, f) {
- var j = 0;
- for (var e in f) {
- j += f[e].units
- }
- d += (g - h) * j / 100
- });
- return this.getProjectCalendar().convertMSDurationToUnit(d,
- b || this.getEffortUnit())
- },
- updateAssignments : function() {
- var b = {};
- var a = this.getStartDate();
- var d = this.getEndDate();
- var c = 0;
- this.forEachAvailabilityIntervalWithResources({
- startDate : a,
- endDate : d
- }, function(h, g, f) {
- for (var i in f) {
- c += g - h
- }
- });
- if (!c) {
- return
- }
- var e = this.getEffort(Sch.util.Date.MILLI);
- Ext.Array.each(this.getAssignments(), function(f) {
- f.setUnits(e / c * 100)
- })
- },
- updateEffortBasedOnDuration : function() {
- this.setEffort(this.calculateEffort(this.getStartDate(), this
- .getEndDate()))
- },
- updateDurationBasedOnEffort : function() {
- this.setEndDate(this.calculateEffortDrivenEndDate(this.getStartDate(),
- this.getEffort(), this.getEffortUnit()), false)
- },
- onPotentialEffortChange : function() {
- if (this.getSchedulingMode() === "FixedDuration") {
- this.updateEffortBasedOnDuration()
- }
- if (this.getSchedulingMode() === "DynamicAssignment") {
- this.updateAssignments()
- }
- },
- onAssignmentMutation : function() {
- if (this.getSchedulingMode() === "FixedDuration") {
- this.updateEffortBasedOnDuration()
- }
- if (this.getSchedulingMode() === "EffortDriven") {
- this.updateDurationBasedOnEffort()
- }
- },
- onAssignmentStructureMutation : function() {
- if (this.getSchedulingMode() == "FixedDuration") {
- this.updateEffortBasedOnDuration()
- }
- if (this.getSchedulingMode() === "EffortDriven") {
- this.updateDurationBasedOnEffort()
- }
- if (this.getSchedulingMode() === "DynamicAssignment") {
- this.updateAssignments()
- }
- },
- adjustToCalendar : function() {
- if (this.get("leaf") && !this.isManuallyScheduled()) {
- var a = this.hasIncomingDependencies();
- if (a) {
- this.constrain()
- } else {
- this.setStartDate(this.getStartDate(), true, true)
- }
- }
- },
- isEditable : function(a) {
- if ((a === this.durationField || a === this.endDateField)
- && this.getSchedulingMode() === "EffortDriven") {
- return false
- }
- if (a === this.effortField
- && this.getSchedulingMode() === "FixedDuration") {
- return false
- }
- return true
- },
- isDraggable : function() {
- return this.getDraggable()
- },
- isResizable : function() {
- return this.getResizable()
- },
- ensureSingleSyncForMethod : function() {
- return function() {
- var a = this.getTaskStore(true);
- var c;
- if (a && a.autoSync && !a.autoSyncSuspended) {
- c = true;
- a.suspendAutoSync()
- }
- var b = this.callParent(arguments);
- if (c) {
- a.resumeAutoSync();
- a.sync()
- }
- return b
- }
- },
- getId : function() {
- var a = this.data[this.idProperty];
- return a && a !== "root" ? a : null
- },
- join : function(b) {
- var a = this.store;
- if (Ext.getVersion("extjs").isGreaterThanOrEqual("4.1.3") && a) {
- if (b instanceof Ext.data.TreeStore && a.treeStore == b) {
- return
- }
- if (b instanceof Ext.data.NodeStore && b.treeStore == a) {
- this.unjoin(a)
- }
- }
- this.callParent(arguments)
- }
- }, function() {
- Ext.data.NodeInterface.decorate(this);
- var a = ["addPredecessor", "addSubtask", "addSuccessor", "indent",
- "outdent", "remove", "insertBefore", "appendChild"];
- this.override({
- remove : function() {
- var b = this.parentNode;
- var c = this.callParent(arguments);
- if (b.convertEmptyParentToLeaf && b.childNodes.length === 0
- && this.getTaskStore().recalculateParents) {
- b.set("leaf", true)
- }
- return c
- },
- insertBefore : function(b) {
- if (this.phantom) {
- this.data[this.phantomIdField] = b.data[this.phantomParentIdField] = this.internalId
- }
- return this.callParent(arguments)
- },
- appendChild : function(b) {
- if (this.phantom) {
- this.data[this.phantomIdField] = b.data[this.phantomParentIdField] = this.internalId
- }
- return this.callParent(arguments)
- }
- });
- Ext.each(a, function(c) {
- var b = {};
- b[c] = this.prototype
- .ensureSingleSyncForMethod(this.prototype[c]);
- this.override(b)
- }, this)
- });
- Ext.define("Gnt.util.DurationParser", {
- requires : ["Sch.util.Date"],
- parseNumberFn : null,
- durationRegex : null,
- allowDecimals : true,
- unitsRegex : {
- MILLI : /^ms$|^mil/i,
- SECOND : /^s$|^sec/i,
- MINUTE : /^m$|^min/i,
- HOUR : /^h$|^hr$|^hour/i,
- DAY : /^d$|^day/i,
- WEEK : /^w$|^wk|^week/i,
- MONTH : /^mo|^mnt/i,
- QUARTER : /^q$|^quar|^qrt/i,
- YEAR : /^y$|^yr|^year/i
- },
- constructor : function(a) {
- Ext.apply(this, a);
- if (!this.durationRegex) {
- this.durationRegex = this.allowDecimals
- ? /^\s*([\-+]?\d+(?:[.,]\d+)?)\s*(\w+)?/i
- : /^\s*([\-+]?\d+)(?![.,])\s*(\w+)?/i
- }
- },
- parse : function(c) {
- var a = this.durationRegex.exec(c);
- if (c == null || !a) {
- return null
- }
- var e = this.parseNumberFn(a[1]);
- var b = a[2];
- var d;
- if (b) {
- Ext.iterate(this.unitsRegex, function(f, g) {
- if (g.test(b)) {
- d = Sch.util.Date.getUnitByName(f);
- return false
- }
- });
- if (!d) {
- return null
- }
- }
- return {
- value : e,
- unit : d
- }
- }
- });
- Ext.define("Gnt.util.DependencyParser", {
- requires : ["Gnt.util.DurationParser"],
- separator : ";",
- parseNumberFn : null,
- dependencyRegex : /(-?\d+)(SS|SF|FS|FF)?([\+\-])?/i,
- types : ["SS", "SF", "FS", "FF"],
- constructor : function(a) {
- this.durationParser = new Gnt.util.DurationParser(a);
- Ext.apply(this, a)
- },
- parse : function(g) {
- if (!g) {
- return []
- }
- var c = g.split(this.separator);
- var j = [];
- var b = this.dependencyRegex;
- for (var e = 0; e < c.length; e++) {
- var f = b.exec(c[e]);
- var d = {};
- if (!f) {
- return null
- }
- d.taskId = parseInt(f[1], 10);
- if (!f[2] && f[3]) {
- return null
- }
- d.type = this.types.indexOf((f[2] || "FS").toUpperCase());
- var h = f[3];
- if (h) {
- var a = this.durationParser.parse(c[e].substring(c[e]
- .indexOf(h)));
- if (!a) {
- return null
- }
- d.lag = a.value;
- d.lagUnit = a.unit || "d"
- }
- j.push(d)
- }
- return j
- }
- });
- Ext.define("Gnt.data.Calendar", {
- extend : "Ext.data.Store",
- requires : ["Ext.Date", "Gnt.model.CalendarDay", "Sch.model.Range",
- "Sch.util.Date"],
- model : "Gnt.model.CalendarDay",
- daysPerMonth : 30,
- daysPerWeek : 7,
- hoursPerDay : 24,
- unitsInMs : null,
- defaultNonWorkingTimeCssCls : "gnt-holiday",
- weekendsAreWorkdays : false,
- weekendFirstDay : 6,
- weekendSecondDay : 0,
- holidaysCache : null,
- availabilityIntervalsCache : null,
- weekAvailability : null,
- defaultWeekAvailability : null,
- nonStandardWeeksByStartDate : null,
- nonStandardWeeksStartDates : null,
- calendarId : null,
- parent : null,
- defaultAvailability : ["00:00-24:00"],
- name : null,
- statics : {
- getCalendar : function(a) {
- if (a instanceof Gnt.data.Calendar) {
- return a
- }
- return Ext.data.StoreManager.lookup("GNT_CALENDAR:" + a)
- },
- getAllCalendars : function() {
- var a = [];
- Ext.data.StoreManager.each(function(b) {
- if (b instanceof Gnt.data.Calendar) {
- a.push(b)
- }
- });
- return a
- }
- },
- constructor : function(a) {
- a = a || {};
- if (a.calendarId) {
- this.storeId = "GNT_CALENDAR:" + a.calendarId
- }
- this.callParent(arguments);
- var c = this;
- var b = this.parent = Gnt.data.Calendar.getCalendar(a.parent);
- if (a.parent && !this.parent) {
- throw new Error("Invalid parent specified for calendar")
- }
- this.unitsInMs = {
- MILLI : 1,
- SECOND : 1000,
- MINUTE : 60 * 1000,
- HOUR : 60 * 60 * 1000,
- DAY : this.hoursPerDay * 60 * 60 * 1000,
- WEEK : this.daysPerWeek * this.hoursPerDay * 60 * 60 * 1000,
- MONTH : this.daysPerMonth * this.hoursPerDay * 60 * 60 * 1000,
- QUARTER : 3 * this.daysPerMonth * 24 * 60 * 60 * 1000,
- YEAR : 4 * 3 * this.daysPerMonth * 24 * 60 * 60 * 1000
- };
- this.defaultWeekAvailability = this
- .getDefaultWeekAvailability(this.weekendsAreWorkdays);
- Ext.Array.each(a.weekAvailability || [], function(e, d) {
- if (e) {
- e.setDate(new Date(0, 0, d));
- e.set(e.idProperty, "WEEKDAY:" + d)
- }
- c.add(e)
- });
- this.holidaysCache = {};
- this.availabilityIntervalsCache = {};
- this.on({
- clear : this.clearCache,
- datachanged : this.clearCache,
- update : this.clearCache,
- load : this.updateAvailability,
- scope : this
- });
- b && b.on("clearcache", this.clearCache, this);
- this.updateAvailability()
- },
- getDefaultWeekAvailability : function(f) {
- if (arguments.length === 0) {
- f = this.weekendsAreWorkdays
- }
- var e = this.defaultAvailability;
- var d = this.weekendFirstDay;
- var a = this.weekendSecondDay;
- var c = [];
- for (var b = 0; b < 7; b++) {
- c.push(f || b != d && b != a ? new Gnt.model.CalendarDay({
- Availability : Ext.Array.clone(e),
- IsWorkingDay : true
- }) : new Gnt.model.CalendarDay({
- Availability : []
- }))
- }
- return c
- },
- updateAvailability : function() {
- var a = this.weekAvailability = [];
- var c = this.nonStandardWeeksStartDates = [];
- var b = this.nonStandardWeeksByStartDate = {};
- this.each(function(e) {
- var i = e.getId();
- var g = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/
- .exec(i);
- var f;
- if (g) {
- var d = Ext.Date.parse(g[2], "Y/m/d") - 0;
- var h = Ext.Date.parse(g[3], "Y/m/d") - 0;
- f = g[1];
- if (!b[d]) {
- b[d] = {
- startDate : new Date(d),
- endDate : new Date(h),
- name : e.getName(),
- weekAvailability : []
- };
- c.push(d)
- }
- b[d].weekAvailability[f] = e
- }
- g = /^WEEKDAY:(\d+)$/.exec(i);
- if (g) {
- f = g[1];
- if (f < 0 || f > 6) {
- throw new Error("Incorrect week day index")
- }
- a[f] = e
- }
- });
- c.sort()
- },
- intersectsWithCurrentWeeks : function(b, d) {
- var e = this.nonStandardWeeksStartDates;
- var c = this.nonStandardWeeksByStartDate;
- var a = false;
- Ext.Array.each(e, function(h) {
- var f = c[h].startDate;
- var g = c[h].endDate;
- if (f <= b && b < g || f < d && d <= g) {
- a = true;
- return false
- }
- });
- return a
- },
- addNonStandardWeek : function(b, c, a) {
- b = Ext.Date.clearTime(new Date(b));
- c = Ext.Date.clearTime(new Date(c));
- if (this.intersectsWithCurrentWeeks(b, c)) {
- throw new Error("Can not add intersecting week")
- }
- Ext.Array.each(a, function(d, e) {
- if (d) {
- d.set(d.idProperty, e + "-"
- + Ext.Date.format(b, "Y/m/d") + "-"
- + Ext.Date.format(c, "Y/m/d"))
- }
- });
- b = b - 0;
- c = c - 0;
- this.nonStandardWeeksStartDates.push(b);
- this.nonStandardWeeksStartDates.sort();
- this.nonStandardWeeksByStartDate[b] = {
- startDate : new Date(b),
- endDate : new Date(c),
- weekAvailability : a
- };
- this.add(Ext.Array.clean(a))
- },
- getNonStandardWeekByStartDate : function(a) {
- return this.nonStandardWeeksByStartDate[Ext.Date.clearTime(new Date(a))
- - 0]
- },
- getNonStandardWeekByDate : function(d) {
- d = Ext.Date.clearTime(new Date(d)) - 0;
- var e = this.nonStandardWeeksStartDates;
- var a = this.nonStandardWeeksByStartDate;
- for (var c = 0; c < e.length; c++) {
- var b = a[e[c]];
- if (b.startDate <= d && d <= b.endDate) {
- return b
- }
- }
- return null
- },
- removeNonStandardWeek : function(a) {
- a = Ext.Date.clearTime(new Date(a)) - 0;
- var b = this.getNonStandardWeekByStartDate(a);
- if (!b) {
- return
- }
- this.remove(Ext.Array.clean(b.weekAvailability));
- delete this.nonStandardWeeksByStartDate[a];
- Ext.Array.remove(this.nonStandardWeeksStartDates, a)
- },
- clearCache : function() {
- this.holidaysCache = {};
- this.availabilityIntervalsCache = {};
- this.fireEvent("clearcache", this)
- },
- setWeekendsAreWorkDays : function(a) {
- if (a !== this.weekendsAreWorkdays) {
- this.weekendsAreWorkdays = a;
- this.clearCache();
- this.defaultWeekAvailability = this
- .getDefaultWeekAvailability(this.weekendsAreWorkdays)
- }
- },
- areWeekendsWorkDays : function() {
- return this.weekendsAreWorkdays
- },
- getCalendarDay : function(b) {
- b = typeof b == "number" ? new Date(b) : b;
- var a = this.getOverrideDay(b);
- if (a) {
- return a
- }
- return this.getDefaultCalendarDay(b.getDay(), b)
- },
- getOverrideDay : function(a) {
- var b = this.getOwnCalendarDay(a);
- if (b) {
- return b
- }
- if (this.parent) {
- return this.parent.getOverrideDay(a)
- }
- return null
- },
- getOwnCalendarDay : function(a) {
- a = typeof a == "number" ? new Date(a) : a;
- return this.getById(Ext.Date.clearTime(a, true) - 0)
- },
- getDefaultCalendarDay : function(c, b) {
- if (b) {
- var a = this.getNonStandardWeekByDate(b);
- if (a && a.weekAvailability[c]) {
- return a.weekAvailability[c]
- }
- }
- if (this.weekAvailability[c]) {
- return this.weekAvailability[c]
- }
- if (this.parent) {
- return this.parent.getDefaultCalendarDay(c)
- }
- return this.defaultWeekAvailability[c]
- },
- isHoliday : function(c) {
- var b = c - 0;
- var d = this.holidaysCache;
- if (d[b] != null) {
- return d[b]
- }
- c = typeof c == "number" ? new Date(c) : c;
- var a = this.getCalendarDay(c);
- if (!a) {
- throw "Can't find day for " + c
- }
- return d[b] = !a.getIsWorkingDay()
- },
- isWeekend : function(b) {
- var a = b.getDay();
- return a === this.weekendFirstDay || a === this.weekendSecondDay
- },
- isWorkingDay : function(a) {
- return !this.isHoliday(a)
- },
- convertMSDurationToUnit : function(a, b) {
- return a / this.unitsInMs[Sch.util.Date.getNameOfUnit(b)]
- },
- convertDurationToMs : function(b, a) {
- return b * this.unitsInMs[Sch.util.Date.getNameOfUnit(a)]
- },
- getHolidaysRanges : function(d, g, a) {
- if (d > g) {
- Ext.Error.raise("startDate can't be bigger than endDate")
- }
- d = Ext.Date.clearTime(d, true);
- g = Ext.Date.clearTime(g, true);
- var c = [], h, e;
- for (e = d; e < g; e = Sch.util.Date.getNext(e, Sch.util.Date.DAY, 1)) {
- if (this.isHoliday(e)
- || (this.weekendsAreWorkdays && a && this.isWeekend(e))) {
- var i = this.getCalendarDay(e);
- var j = i && i.getCls() || this.defaultNonWorkingTimeCssCls;
- var f = Sch.util.Date.getNext(e, Sch.util.Date.DAY, 1);
- if (!h) {
- h = {
- StartDate : e,
- EndDate : f,
- Cls : j
- }
- } else {
- if (h.Cls == j) {
- h.EndDate = f
- } else {
- c.push(h);
- h = {
- StartDate : e,
- EndDate : f,
- Cls : j
- }
- }
- }
- } else {
- if (h) {
- c.push(h);
- h = null
- }
- }
- }
- if (h) {
- c.push(h)
- }
- var b = [];
- Ext.each(c, function(k) {
- b.push(Ext.create("Sch.model.Range", {
- StartDate : k.StartDate,
- EndDate : k.EndDate,
- Cls : k.Cls
- }))
- });
- return b
- },
- forEachAvailabilityInterval : function(r, f, p) {
- p = p || this;
- var l = this;
- var d = r.startDate;
- var j = r.endDate;
- var o = r.isForward !== false;
- if (o ? !d : !j) {
- throw new Error("At least `startDate` or `endDate` is required, depending from the `isForward` option")
- }
- var a = new Date(o ? d : j);
- var q = o ? !j : !d;
- var c = Sch.util.Date;
- while (q || (o ? a < j : a > d)) {
- var h = this.getAvailabilityIntervalsFor(a - (o ? 0 : 1));
- for (var g = o ? 0 : h.length - 1; o ? g < h.length : g >= 0; o
- ? g++
- : g--) {
- var b = h[g];
- var k = b.startDate;
- var n = b.endDate;
- if (k >= j || n <= d) {
- continue
- }
- var e = k < d ? d : k;
- var m = n > j ? j : n;
- if (f.call(p, e, m) === false) {
- return false
- }
- }
- a = o ? c.getStartOfNextDay(a) : c.getEndOfPreviousDay(a)
- }
- },
- calculateDuration : function(a, d, b) {
- var c = 0;
- this.forEachAvailabilityInterval({
- startDate : a,
- endDate : d
- }, function(g, f) {
- var e = g.getTimezoneOffset() - f.getTimezoneOffset();
- c += f - g + e * 60 * 1000
- });
- return this.convertMSDurationToUnit(c, b)
- },
- calculateEndDate : function(a, f, b) {
- if (!f) {
- return new Date(a)
- }
- var e = Sch.util.Date, d;
- f = this.convertDurationToMs(f, b);
- var c = f === 0 && Ext.Date.clearTime(a, true) - a === 0 ? e.add(a,
- Sch.util.Date.DAY, -1) : a;
- this.forEachAvailabilityInterval({
- startDate : c
- }, function(i, h) {
- var j = h - i;
- var g = i.getTimezoneOffset() - h.getTimezoneOffset();
- if (j >= f) {
- d = new Date(i - 0 + f);
- return false
- } else {
- f -= j + g * 60 * 1000
- }
- });
- return d
- },
- calculateStartDate : function(d, c, b) {
- if (!c) {
- return new Date(d)
- }
- var a;
- c = this.convertDurationToMs(c, b);
- this.forEachAvailabilityInterval({
- endDate : d,
- isForward : false
- }, function(f, e) {
- var g = e - f;
- if (g >= c) {
- a = new Date(e - c);
- return false
- } else {
- c -= g
- }
- });
- return a
- },
- skipNonWorkingTime : function(a, b) {
- this.forEachAvailabilityInterval(b ? {
- startDate : a
- } : {
- endDate : a,
- isForward : false
- }, function(d, c) {
- a = b ? d : c;
- return false
- });
- return new Date(a)
- },
- skipWorkingTime : function(a, c, b) {
- return c >= 0 ? this.calculateEndDate(a, c, b) : this
- .calculateStartDate(a, -c, b)
- },
- getAvailabilityIntervalsFor : function(a) {
- a = Ext.Date.clearTime(new Date(a)) - 0;
- if (this.availabilityIntervalsCache[a]) {
- return this.availabilityIntervalsCache[a]
- }
- return this.availabilityIntervalsCache[a] = this.getCalendarDay(a)
- .getAvailabilityIntervalsFor(a)
- },
- getParentableCalendars : function() {
- var c = this, a = [], d = Gnt.data.Calendar.getAllCalendars();
- var b = function(e) {
- if (!e.parent) {
- return false
- }
- if (e.parent == c) {
- return true
- }
- return b(e.parent)
- };
- Ext.Array.each(d, function(e) {
- if (e === c) {
- return
- }
- if (!b(e)) {
- a.push({
- Id : e.calendarId,
- Name : e.name || e.calendarId
- })
- }
- });
- return a
- }
- });
- Ext.define("Gnt.data.calendar.BusinessTime", {
- extend : "Gnt.data.Calendar",
- daysPerMonth : 20,
- daysPerWeek : 5,
- hoursPerDay : 8,
- defaultAvailability : ["08:00-12:00", "13:00-17:00"]
- });
- Ext.define("Gnt.data.TaskStore", {
- extend : "Ext.data.TreeStore",
- requires : ["Sch.patches.TreeStore", "Gnt.model.Task", "Gnt.data.Calendar"],
- mixins : ["Sch.data.mixin.BufferableTreeStore",
- "Sch.data.mixin.FilterableTreeStore", "Sch.data.mixin.EventStore"],
- model : "Gnt.model.Task",
- calendar : null,
- dependencyStore : null,
- resourceStore : null,
- assignmentStore : null,
- weekendsAreWorkdays : false,
- buffered : false,
- pageSize : null,
- cascadeChanges : false,
- batchSync : true,
- recalculateParents : true,
- skipWeekendsDuringDragDrop : true,
- cascadeDelay : 0,
- cascading : false,
- isFillingRoot : false,
- constructor : function(c) {
- this.addEvents("root-fill-start", "root-fill-end", "filter",
- "clearfilter", "beforecascade", "cascade");
- c = c || {};
- if (!c.calendar) {
- var a = {};
- if (c.hasOwnProperty("weekendsAreWorkdays")) {
- a.weekendsAreWorkdays = c.weekendsAreWorkdays
- } else {
- if (this.self.prototype.hasOwnProperty("weekendsAreWorkdays")
- && this.self != Gnt.data.TaskStore) {
- a.weekendsAreWorkdays = this.weekendsAreWorkdays
- }
- }
- c.calendar = new Gnt.data.Calendar(a)
- }
- this.hasListeners = {};
- this.on({
- "root-fill-end" : this.onRootFillEnd,
- remove : this.onTaskDeleted,
- beforesync : this.onTaskStoreBeforeSync,
- write : this.onTaskStoreWrite,
- scope : this
- });
- var b = c.dependencyStore;
- if (b) {
- delete c.dependencyStore;
- this.setDependencyStore(b)
- }
- var d = c.resourceStore;
- if (d) {
- delete c.resourceStore;
- this.setResourceStore(d)
- }
- var f = c.assignmentStore;
- if (f) {
- delete c.assignmentStore;
- this.setAssignmentStore(f)
- }
- var e = c.calendar;
- if (e) {
- delete c.calendar;
- this.setCalendar(e)
- }
- this.callParent([c]);
- if (Ext.data.reader.Xml
- && this.getProxy().getReader() instanceof Ext.data.reader.Xml) {
- Ext.override(this.getProxy().getReader(), {
- extractData : function(g) {
- var h = this.record;
- if (h != g.nodeName) {
- g = Ext.DomQuery.select(">" + h, g)
- } else {
- g = [g]
- }
- return Ext.data.reader.Xml.superclass.extractData
- .apply(this, [g])
- }
- })
- }
- if (this.autoSync && this.batchSync) {
- this.sync = Ext.Function.createBuffered(this.sync, 500)
- }
- this.initTreeFiltering();
- this.initTreeBuffering()
- },
- load : function() {
- this.un("remove", this.onTaskDeleted, this);
- this.callParent(arguments);
- this.on("remove", this.onTaskDeleted, this)
- },
- loadData : function(B, w) {
- var z = this, r = z.getRootNode(), c = w ? w.addRecords : false, t = w
- ? w.syncStore
- : false;
- z.suspendAutoSync();
- z.suspendEvents();
- if (!c && r) {
- r.removeAll()
- }
- if (!z.getRootNode()) {
- r = z.setRootNode()
- }
- if (!B.length) {
- return
- } else {
- var f = B.length, e = z.model, n = [], u = (typeof B[0].get === "function"), b, p, o, x, y, A, v, m, h;
- for (var s = 0; s < f; s++) {
- p = z.getById(B[s].getId ? B[s].getId() : B[s].Id);
- b = 0;
- if (p) {
- x = u ? B[s].get("parentId") : B[s].parentId;
- y = p.get("parentId");
- A = u ? B[s].get("index") : B[s].index;
- v = p.get("index");
- if (u) {
- p.set(B[s].data)
- } else {
- p.set(B[s])
- }
- if (((x || x === null) ? (x !== y) : false)
- || (A ? (A !== v) : false)) {
- m = x === null ? r : z.getById(x);
- h = y === null ? r : z.getById(y)
- } else {
- b = 1
- }
- } else {
- p = u ? new e(B[s].data) : new e(B[s]);
- y = p.get("parentId");
- if (y) {
- m = z.getById(y)
- } else {
- if (y === null) {
- m = r
- }
- }
- }
- if (m && !b) {
- z.moveChildren(p, m, h)
- } else {
- if (typeof m === "undefined" && !b) {
- o = {
- node : p,
- index : p.get("index") || 0,
- parentId : p.get("parentId")
- };
- n.push(o)
- }
- }
- if (m && !t) {
- m.commit();
- p.commit();
- if (h) {
- h.commit()
- }
- }
- }
- var g = 0, j = n.length, d, k;
- if (n.length) {
- z.sortNewNodesByIndex(n)
- }
- while (n.length) {
- if (g > n.length - 1) {
- g = 0
- }
- d = n[g];
- k = d.parentId === null ? r : z.getById(d.parentId);
- if (k) {
- var a = z.nodeIsChild(d.node, m);
- if (a) {
- k.insertChild(d.index, d.node);
- z.fixNodeDates(d.node);
- n.splice(g, 1);
- if (!t) {
- k.commit();
- d.node.commit()
- }
- g -= 1
- }
- }
- g += 1;
- if (g === j - 1 && n.length === j) {
- throw "Invalid data, possible infinite loop."
- }
- }
- if (z.nodesToExpand) {
- s = 0;
- for (var q = z.nodesToExpand.length; s < q; s += 1) {
- p = z.nodesToExpand[s];
- if (p.childNodes && p.childNodes.length) {
- p.expand()
- }
- }
- delete z.nodesToExpand
- }
- }
- z.resumeAutoSync();
- z.resumeEvents();
- this.fireEvent("datachanged");
- this.fireEvent("refresh");
- if (t) {
- z.sync()
- }
- },
- sortNewNodesByIndex : function(a) {
- Ext.Array.sort(a, function(b, e) {
- var d = b.index, c = e.index;
- if (d && c) {
- if (d < c) {
- return -1
- } else {
- if (d > c) {
- return 1
- } else {
- return 0
- }
- }
- }
- return 0
- })
- },
- fixNodeDates : function(b) {
- var c = b.calculateDuration(b.getStartDate(), b.getEndDate(), b
- .getDurationUnit()), a;
- b.set({
- Duration : c
- });
- if (this.recalculateParents) {
- if (b.childNodes.length) {
- a = b.getChildAt(0);
- a.recalculateParents()
- } else {
- b.recalculateParents()
- }
- }
- },
- nodeIsChild : function(c, b) {
- var d = b.getId(), a = true;
- if (c.childNodes.length) {
- c.cascadeBy(function(e) {
- if (e.getId() === d) {
- a = false;
- return false
- }
- })
- }
- return a
- },
- moveChildren : function(e, d, c) {
- if (e.get("expanded")) {
- if (!this.nodesToExpand) {
- this.nodesToExpand = []
- }
- this.nodesToExpand.push(e);
- e.set("expanded", false)
- }
- var b, f = this.nodeIsChild(e, d), a = c
- || this.getById(e.get("parentId"));
- if (f) {
- if (e.childNodes.length) {
- b = e.copy(null, true);
- e.removeAll()
- }
- if (a && a.getId() !== d.getId()) {
- a.removeChild(e)
- }
- e.get("index") ? d.insertChild(e.get("index"), e) : d
- .appendChild(e);
- if (b) {
- b.cascadeBy(function(h) {
- if (h !== b) {
- var g = h.copy(null);
- g.get("index") ? e.insertChild(g.get("index"),
- g) : e.appendChild(g)
- }
- })
- }
- this.fixNodeDates(e)
- }
- },
- onNodeAdded : function(c, e) {
- if (!e.normalized && !e.isRoot()) {
- e.normalize()
- }
- if (Ext.isIE) {
- var d = this, b = d.getProxy(), a = b.getReader(), f = e.raw
- || e[e.persistenceProperty], g;
- Ext.Array.remove(d.removed, e);
- if (!e.isLeaf()) {
- g = a.getRoot(f);
- if (g) {
- d.fillNode(e, a.extractData(g));
- if (f[a.root]) {
- delete f[a.root]
- }
- }
- }
- if (d.autoSync && !d.autoSyncSuspended && (e.phantom || e.dirty)) {
- d.sync()
- }
- } else {
- this.callParent(arguments)
- }
- },
- setRootNode : function() {
- var b = this;
- this.tree.setRootNode = Ext.Function.createInterceptor(
- this.tree.setRootNode, function(c) {
- Ext.apply(c, {
- calendar : b.calendar,
- taskStore : b,
- dependencyStore : b.dependencyStore,
- phantom : false,
- dirty : false
- })
- });
- var a = this.callParent(arguments);
- delete this.tree.setRootNode;
- return a
- },
- fillNode : function(g, c) {
- this.isFillingNode = true;
- if (g.isRoot()) {
- this.isFillingRoot = true;
- this.un({
- remove : this.onNodeUpdated,
- append : this.onNodeUpdated,
- insert : this.onNodeUpdated,
- update : this.onTaskUpdated,
- scope : this
- });
- this.fireEvent("root-fill-start", this, g, c)
- }
- var f = this, e = c ? c.length : 0, d = 0, b;
- if (e && f.sortOnLoad && !f.remoteSort && f.sorters && f.sorters.items) {
- b = Ext.create("Ext.util.MixedCollection");
- b.addAll(c);
- b.sort(f.sorters.items);
- c = b.items
- }
- g.set("loaded", true);
- if (this.buffered) {
- for (; d < e; d++) {
- var a = c[d];
- a.__isFilling__ = true;
- g.appendChild(a, true, true);
- this.onNodeAdded(null, a);
- this.tree.registerNode(a)
- }
- } else {
- for (; d < e; d++) {
- c[d].__isFilling__ = true;
- g.appendChild(c[d], false, true)
- }
- }
- if (g.isRoot()) {
- this.getRootNode().cascadeBy(function(h) {
- delete h.__isFilling__
- });
- this.isFillingRoot = false;
- this.on({
- remove : this.onNodeUpdated,
- append : this.onNodeUpdated,
- insert : this.onNodeUpdated,
- update : this.onTaskUpdated,
- scope : this
- });
- this.fireEvent("root-fill-end", this, g, c)
- }
- delete this.isFillingNode;
- return c
- },
- onRootFillEnd : function(b, a) {
- a.normalizeEffort()
- },
- getById : function(a) {
- return this.tree.getNodeById(a)
- },
- setDependencyStore : function(a) {
- if (this.dependencyStore) {
- this.dependencyStore.un({
- add : this.onDependencyAddOrUpdate,
- update : this.onDependencyAddOrUpdate,
- scope : this
- })
- }
- this.dependencyStore = Ext.StoreMgr.lookup(a);
- if (a) {
- a.taskStore = this;
- a.on({
- add : this.onDependencyAddOrUpdate,
- update : this.onDependencyAddOrUpdate,
- scope : this
- })
- }
- },
- setResourceStore : function(a) {
- this.resourceStore = Ext.StoreMgr.lookup(a);
- a.taskStore = this
- },
- getResourceStore : function() {
- return this.resourceStore || null
- },
- setAssignmentStore : function(a) {
- if (this.assignmentStore) {
- this.assignmentStore.un({
- add : this.onAssignmentStructureMutation,
- update : this.onAssignmentMutation,
- remove : this.onAssignmentStructureMutation,
- scope : this
- })
- }
- this.assignmentStore = Ext.StoreMgr.lookup(a);
- a.taskStore = this;
- a.on({
- add : this.onAssignmentStructureMutation,
- update : this.onAssignmentMutation,
- remove : this.onAssignmentStructureMutation,
- scope : this
- })
- },
- getAssignmentStore : function() {
- return this.assignmentStore || null
- },
- renormalizeTasks : function(b, a) {
- if (a instanceof Gnt.model.Task) {
- a.adjustToCalendar()
- } else {
- this.getRootNode().cascadeBy(function(c) {
- c.adjustToCalendar()
- })
- }
- },
- getCalendar : function() {
- return this.calendar || null
- },
- setCalendar : function(c) {
- var b = {
- datachanged : this.renormalizeTasks,
- update : this.renormalizeTasks,
- clear : this.renormalizeTasks,
- scope : this
- };
- if (this.calendar) {
- this.calendar.un(b)
- }
- this.calendar = c;
- c.on(b);
- var a = this.tree && this.getRootNode();
- if (a) {
- a.calendar = c
- }
- },
- filter : function() {
- this.fireEvent("filter", this, arguments)
- },
- clearFilter : function() {
- this.fireEvent("clearfilter", this)
- },
- getCriticalPaths : function() {
- var b = this.getRootNode(), a = [], d = new Date(0);
- b.cascadeBy(function(e) {
- d = Sch.util.Date.max(e.getEndDate(), d)
- });
- b.cascadeBy(function(e) {
- if (d - e.getEndDate() === 0 && !e.isRoot()) {
- a.push(e)
- }
- });
- var c = [];
- Ext.each(a, function(e) {
- c.push(e.getCriticalPaths())
- });
- return c
- },
- onNodeUpdated : function(a, b) {
- if (!this.cascading && this.recalculateParents && !this.isFillingNode) {
- b.recalculateParents()
- }
- },
- onTaskUpdated : function(c, b, a) {
- var d = b.previous;
- if (!this.cascading
- && !this.isFillingNode
- && a !== Ext.data.Model.COMMIT
- && (d && (b.startDateField in d || b.endDateField in d
- || "parentId" in d || b.effortField in d))) {
- if (this.cascadeChanges) {
- Ext.Function.defer(this.cascadeChangesForTask,
- this.cascadeDelay, this, [b])
- }
- if (this.recalculateParents) {
- b.recalculateParents()
- }
- }
- },
- cascadeChangesForTask : function(a) {
- var c = this, b = {
- nbrAffected : 0
- };
- Ext.each(a.getOutgoingDependencies(), function(d) {
- var e = d.getTargetTask();
- if (e) {
- if (!c.cascading) {
- c.fireEvent("beforecascade", c)
- }
- c.cascading = true;
- e.cascadeChanges(c, b, d)
- }
- });
- if (c.cascading) {
- c.cascading = false;
- c.fireEvent("cascade", c, b)
- }
- },
- onTaskDeleted : function(c, b) {
- var a = this.dependencyStore;
- if (a && !b.isReplace && !b.isMove) {
- a.remove(b.getAllDependencies(a))
- }
- },
- onAssignmentMutation : function(c, a) {
- var b = this;
- Ext.each(a, function(e) {
- var d = e.getTask(b);
- if (d) {
- d.onAssignmentMutation(e)
- }
- })
- },
- onAssignmentStructureMutation : function(c, a) {
- var b = this;
- Ext.each(a, function(d) {
- d.getTask(b).onAssignmentStructureMutation(d)
- })
- },
- onDependencyAddOrUpdate : function(b, d) {
- if (this.cascadeChanges) {
- var c = this, a;
- Ext.each(d, function(e) {
- a = e.getTargetTask();
- if (a) {
- a.constrain(c)
- }
- })
- }
- },
- getNewRecords : function() {
- return Ext.Array.filter(this.tree.flatten(), this.filterNew, this)
- },
- getUpdatedRecords : function() {
- return Ext.Array.filter(this.tree.flatten(), this.filterUpdated, this)
- },
- filterNew : function(a) {
- return a.phantom && a.isValid() && a != this.tree.root
- },
- filterUpdated : function(a) {
- return a.dirty && !a.phantom && a.isValid() && a != this.tree.root
- },
- onTaskStoreBeforeSync : function(b, c) {
- var a = b.create;
- if (a) {
- for (var e, d = a.length - 1; d >= 0; d--) {
- e = a[d];
- if (e.isPersistable()) {
- e._phantomId = e.internalId
- } else {
- if (this.autoSync) {
- Ext.Array.remove(a, e)
- }
- }
- }
- if (a.length === 0) {
- delete b.create
- }
- }
- return Boolean((b.create && b.create.length > 0)
- || (b.update && b.update.length > 0)
- || (b.destroy && b.destroy.length > 0))
- },
- onTaskStoreWrite : function(c, b) {
- var d = this.dependencyStore;
- if (!d || b.action !== "create") {
- return
- }
- var a = b.getRecords(), e;
- Ext.each(a, function(f) {
- e = f.getId();
- if (!f.phantom && e !== f._phantomId) {
- Ext.each(d.getNewRecords(), function(g) {
- var i = g.getSourceId();
- var h = g.getTargetId();
- if (i === f._phantomId) {
- g.setSourceId(e)
- } else {
- if (h === f._phantomId) {
- g.setTargetId(e)
- }
- }
- });
- Ext.each(f.childNodes, function(g) {
- if (g.phantom) {
- g.set("parentId", e)
- }
- });
- delete f._phantomId
- }
- })
- },
- getTotalTimeSpan : function() {
- var a = new Date(9999, 0, 1), b = new Date(0), c = Sch.util.Date;
- this.getRootNode().cascadeBy(function(d) {
- if (d.getStartDate()) {
- a = c.min(d.getStartDate(), a)
- }
- if (d.getEndDate()) {
- b = c.max(d.getEndDate(), b)
- }
- });
- a = a < new Date(9999, 0, 1) ? a : null;
- b = b > new Date(0) ? b : null;
- return {
- start : a,
- end : b || a || null
- }
- },
- getCount : function(b) {
- var a = b === false ? 0 : -1;
- this.getRootNode().cascadeBy(function() {
- a++
- });
- return a
- },
- toArray : function() {
- var a = [];
- this.getRootNode().cascadeBy(function(b) {
- a.push(b)
- });
- return a
- },
- remove : function(a) {
- Ext.each(a, function(b) {
- b.remove()
- })
- },
- indent : function(b) {
- b = Ext.isArray(b) ? b : [b];
- var a = Ext.Array.sort(b, function(d, c) {
- return d.data.index > c.data.index
- });
- Ext.each(a, function(c) {
- c.indent()
- })
- },
- outdent : function(b) {
- var a = Ext.Array.sort(b, function(d, c) {
- return d.data.index > c.data.index
- });
- Ext.each(a, function(c) {
- c.indent()
- });
- Ext.each(b, function(c) {
- c.outdent()
- })
- },
- getTasksForResource : function(a) {
- return a.getTasks()
- },
- getEventsForResource : function(a) {
- return this.getTasksForResource(a)
- },
- ensureSingleSyncForMethod : function() {
- return function() {
- var b;
- if (this.autoSync && !this.autoSyncSuspended) {
- b = true;
- this.suspendAutoSync()
- }
- var a = this.callParent(arguments);
- if (b) {
- this.resumeAutoSync();
- this.sync()
- }
- return a
- }
- },
- indexOf : function(a) {
- return a && this.tree.getNodeById(a.internalId) ? 0 : -1
- },
- getByInternalId : function(a) {
- return this.tree.getNodeById(a)
- }
- }, function() {
- var a = ["indent", "outdent", "afterEdit", "remove"];
- Ext.each(a, function(c) {
- var b = {};
- b[c] = this.prototype
- .ensureSingleSyncForMethod(this.prototype[c]);
- this.override(b)
- }, this)
- });
- Ext.define("Gnt.data.DependencyStore", {
- extend : "Ext.data.Store",
- model : "Gnt.model.Dependency",
- constructor : function() {
- this.callParent(arguments);
- this.init()
- },
- init : function() {
- this.on({
- beforesync : this.onBeforeSyncOperation,
- scope : this
- })
- },
- onBeforeSyncOperation : function(a, b) {
- if (a.create) {
- for (var d, c = a.create.length - 1; c >= 0; c--) {
- d = a.create[c];
- if (!d.isPersistable()) {
- Ext.Array.remove(a.create, d)
- }
- }
- if (a.create.length === 0) {
- delete a.create
- }
- }
- return Boolean((a.create && a.create.length > 0)
- || (a.update && a.update.length > 0)
- || (a.destroy && a.destroy.length > 0))
- },
- getDependenciesForTask : function(b) {
- var g = b.getId() || b.internalId;
- var e = [], f = this;
- for (var d = 0, a = f.getCount(); d < a; d++) {
- var c = f.getAt(d);
- if (c.getSourceId() == g || c.getTargetId() == g) {
- e.push(c)
- }
- }
- return e
- },
- getIncomingDependenciesForTask : function(b) {
- var g = b.getId() || b.internalId;
- var e = [], f = this;
- for (var d = 0, a = f.getCount(); d < a; d++) {
- var c = f.getAt(d);
- if (c.getTargetId() == g) {
- e.push(c)
- }
- }
- return e
- },
- getOutgoingDependenciesForTask : function(b) {
- var g = b.getId() || b.internalId;
- var e = [], f = this;
- for (var d = 0, a = f.getCount(); d < a; d++) {
- var c = f.getAt(d);
- if (c.getSourceId() == g) {
- e.push(c)
- }
- }
- return e
- },
- hasTransitiveDependency : function(d, b, a) {
- var c = this;
- return this.findBy(function(f) {
- var e = f.getTargetId();
- if (f.getSourceId() === d) {
- return (e === b && f !== a) ? true : c
- .hasTransitiveDependency(f
- .getTargetId(), b, a)
- }
- }) >= 0
- },
- isValidDependency : function(h, b, e) {
- var f = true;
- var d, c, a;
- if (h instanceof Gnt.model.Dependency) {
- d = h.getSourceId();
- c = this.getSourceTask(d);
- b = h.getTargetId();
- a = this.getTargetTask(b)
- } else {
- d = h;
- c = this.getSourceTask(d);
- a = this.getTargetTask(b)
- }
- if (!e && h instanceof Gnt.model.Dependency) {
- f = h.isValid()
- } else {
- f = d && b && d !== b
- }
- if (f) {
- if (c && a && (c.contains(a) || a.contains(c))) {
- f = false
- }
- var g = e || (h instanceof Gnt.model.Dependency);
- if (f
- && ((!g && this.areTasksLinked(d, b)) || this
- .hasTransitiveDependency(b, d, g ? h : null))) {
- f = false
- }
- }
- return f
- },
- areTasksLinked : function(c, e) {
- var d = this;
- var b = c instanceof Gnt.model.Task
- ? (c.getId() || c.internalId)
- : c;
- var a = e instanceof Gnt.model.Task
- ? (e.getId() || e.internalId)
- : e;
- return !!this.getByTaskIds(b, a)
- },
- getByTaskIds : function(c, b) {
- var d = this;
- var a = this.findBy(function(g) {
- var e = g.getTargetId(), f = g.getSourceId();
- if ((f === c && e === b) || (f === b && e === c)) {
- return true
- }
- });
- return this.getAt(a)
- },
- getSourceTask : function(a) {
- var b = a instanceof Gnt.model.Dependency ? a.getSourceId() : a;
- return this.getTaskStore().getById(b)
- },
- getTargetTask : function(a) {
- var b = a instanceof Gnt.model.Dependency ? a.getTargetId() : a;
- return this.getTaskStore().getById(b)
- },
- getTaskStore : function() {
- return this.taskStore
- }
- });
- Ext.define("Gnt.data.ResourceStore", {
- requires : ["Gnt.model.Resource"],
- extend : "Sch.data.ResourceStore",
- model : "Gnt.model.Resource",
- taskStore : null,
- getTaskStore : function() {
- return this.taskStore || null
- },
- getAssignmentStore : function() {
- return this.assignmentStore || null
- },
- getByInternalId : function(a) {
- return this.data.getByKey(a) || this.getById(a)
- }
- });
- Ext.define("Gnt.data.AssignmentStore", {
- requires : ["Gnt.model.Assignment"],
- extend : "Ext.data.Store",
- model : "Gnt.model.Assignment",
- taskStore : null,
- getTaskStore : function() {
- return this.taskStore
- },
- getResourceStore : function() {
- return this.getTaskStore().resourceStore
- },
- getByInternalId : function(a) {
- return this.data.getByKey(a) || this.getById(a)
- }
- });
- Ext.define("Gnt.template.Task", {
- extend : "Ext.XTemplate",
- constructor : function(a) {
- this
- .callParent([
- '<div class="sch-event-wrap '
- + a.baseCls
- + ' x-unselectable" style="left:{leftOffset}px;">'
- + (a.leftLabel
- ? '<div class="sch-gantt-labelct sch-gantt-labelct-left"><label class="sch-gantt-label sch-gantt-label-left">{leftLabel}</label></div>'
- : "")
- + '<div id="'
- + a.prefix
- + '{id}" class="sch-gantt-item sch-gantt-task-bar {cls}" unselectable="on" style="width:{width}px;{style}">'
- + (a.enableDependencyDragDrop
- ? '<div unselectable="on" class="sch-gantt-terminal sch-gantt-terminal-start"></div>'
- : "")
- + ((a.resizeHandles === "both" || a.resizeHandles === "left")
- ? '<div class="sch-resizable-handle sch-gantt-task-handle sch-resizable-handle-west"></div>'
- : "")
- + '<div class="sch-gantt-progress-bar" style="width:{percentDone}%;{progressBarStyle}" unselectable="on"> </div>'
- + ((a.resizeHandles === "both" || a.resizeHandles === "right")
- ? '<div class="sch-resizable-handle sch-gantt-task-handle sch-resizable-handle-east"></div>'
- : "")
- + (a.enableDependencyDragDrop
- ? '<div unselectable="on" class="sch-gantt-terminal sch-gantt-terminal-end"></div>'
- : "")
- + (a.enableProgressBarResize
- ? '<div style="left:{percentDone}%" class="sch-gantt-progressbar-handle"></div>'
- : "")
- + "</div>"
- + (a.rightLabel
- ? '<div class="sch-gantt-labelct sch-gantt-labelct-right" style="left:{width}px"><label class="sch-gantt-label sch-gantt-label-right">{rightLabel}</label></div>'
- : "") + "</div>", {
- compiled : true,
- disableFormats : true
- }])
- }
- });
- Ext.define("Gnt.template.Milestone", {
- extend : "Ext.XTemplate",
- constructor : function(a) {
- this
- .callParent([
- '<div class="sch-event-wrap '
- + a.baseCls
- + ' x-unselectable" style="left:{leftOffset}px">'
- + (a.leftLabel
- ? '<div class="sch-gantt-labelct sch-gantt-labelct-left"><label class="sch-gantt-label sch-gantt-label-left">{leftLabel}</label></div>'
- : "")
- + (a.printable
- ? ('<img id="' + a.prefix
- + '{id}" src="' + a.imgSrc + '" class="sch-gantt-item sch-gantt-milestone-diamond {cls}" unselectable="on" style="{style}" />')
- : ('<div id="'
- + a.prefix
- + '{id}" class="sch-gantt-item sch-gantt-milestone-diamond {cls}" unselectable="on" style="{style}">'
- + (a.enableDependencyDragDrop
- ? '<div class="sch-gantt-terminal sch-gantt-terminal-start"></div><div class="sch-gantt-terminal sch-gantt-terminal-end"></div>'
- : "") + "</div>"))
- + (a.rightLabel
- ? '<div class="sch-gantt-labelct sch-gantt-labelct-right" style="left:{width}px"><label class="sch-gantt-label sch-gantt-label-right">{rightLabel}</label></div>'
- : "") + "</div>", {
- compiled : true,
- disableFormats : true
- }])
- }
- });
- Ext.define("Gnt.template.ParentTask", {
- extend : "Ext.XTemplate",
- constructor : function(a) {
- this
- .callParent([
- '<div class="sch-event-wrap '
- + a.baseCls
- + ' x-unselectable" style="left:{leftOffset}px;">'
- + (a.leftLabel
- ? '<div class="sch-gantt-labelct sch-gantt-labelct-left"><label class="sch-gantt-label sch-gantt-label-left">{leftLabel}</label></div>'
- : "")
- + '<div id="'
- + a.prefix
- + '{id}" class="sch-gantt-item sch-gantt-parenttask-bar {cls}" style="width:{width}px; {style}"><div class="sch-gantt-progress-bar" style="width:{percentDone}%;{progressBarStyle}"> </div>'
- + (a.enableDependencyDragDrop
- ? '<div class="sch-gantt-terminal sch-gantt-terminal-start"></div>'
- : "")
- + '<div class="sch-gantt-parenttask-arrow sch-gantt-parenttask-leftarrow"></div><div class="sch-gantt-parenttask-arrow sch-gantt-parenttask-rightarrow"></div>'
- + (a.enableDependencyDragDrop
- ? '<div class="sch-gantt-terminal sch-gantt-terminal-end"></div>'
- : "")
- + "</div>"
- + (a.rightLabel
- ? '<div class="sch-gantt-labelct sch-gantt-labelct-right" style="left:{width}px"><label class="sch-gantt-label sch-gantt-label-right">{rightLabel}</label></div>'
- : "") + "</div>", {
- compiled : true,
- disableFormats : true
- }])
- }
- });
- Ext.define("Gnt.Tooltip", {
- extend : "Ext.ToolTip",
- requires : ["Ext.Template"],
- startText : "Starts: ",
- endText : "Ends: ",
- durationText : "Duration:",
- mode : "startend",
- cls : "sch-tip",
- height : 40,
- autoHide : false,
- anchor : "b-tl",
- maskOnDisable : false,
- initComponent : function() {
- if (this.mode === "startend" && !this.startEndTemplate) {
- this.startEndTemplate = new Ext.Template('<div class="sch-timetipwrap {cls}"><div>'
- + this.startText
- + "{startText}</div><div>"
- + this.endText
- + "{endText}</div></div>").compile()
- }
- if (this.mode === "duration" && !this.durationTemplate) {
- this.durationTemplate = new Ext.Template(
- '<div class="sch-timetipwrap {cls}">', "<div>"
- + this.startText + " {startText}</div>", "<div>"
- + this.durationText + " {duration} {unit}</div>",
- "</div>").compile()
- }
- this.callParent(arguments)
- },
- update : function(e, b, d, a) {
- var c;
- if (this.mode === "duration") {
- c = this.getDurationContent(e, b, d, a)
- } else {
- c = this.getStartEndContent(e, b, d, a)
- }
- this.callParent([c])
- },
- getStartEndContent : function(b, f, a, h) {
- var e = this.gantt, i = e.getFormattedDate(b), d = i, g;
- if (f - b > 0) {
- d = e.getFormattedEndDate(f, b)
- }
- var c = {
- cls : a ? "sch-tip-ok" : "sch-tip-notok",
- startText : i,
- endText : d
- };
- if (this.showClock) {
- Ext.apply(c, {
- startHourDegrees : roundedStart.getHours() * 30,
- startMinuteDegrees : roundedStart.getMinutes() * 6
- });
- if (f) {
- Ext.apply(c, {
- endHourDegrees : g.getHours() * 30,
- endMinuteDegrees : g.getMinutes() * 6
- })
- }
- }
- return this.startEndTemplate.apply(c)
- },
- getDurationContent : function(f, b, d, a) {
- var c = a.getDurationUnit() || Sch.util.Date.DAY;
- var e = a.calculateDuration(f, b, c);
- return this.durationTemplate.apply({
- cls : d ? "sch-tip-ok" : "sch-tip-notok",
- startText : this.gantt.getFormattedDate(f),
- duration : parseFloat(Ext.Number.toFixed(e, 1)),
- unit : Sch.util.Date.getReadableNameOfUnit(c, e > 1)
- })
- },
- show : function(a) {
- if (a) {
- this.setTarget(a)
- }
- this.callParent([])
- }
- });
- Ext.define("Gnt.feature.TaskDragDrop", {
- extend : "Ext.dd.DragZone",
- requires : ["Gnt.Tooltip", "Ext.dd.StatusProxy", "Ext.dd.ScrollManager"],
- onDragEnter : Ext.emptyFn,
- onDragOut : Ext.emptyFn,
- constructor : function(a) {
- a = a || {};
- Ext.apply(this, a);
- this.proxy = this.proxy || Ext.create("Ext.dd.StatusProxy", {
- shadow : false,
- dropAllowed : "sch-gantt-dragproxy",
- dropNotAllowed : "sch-gantt-dragproxy",
- ensureAttachedToBody : Ext.emptyFn
- });
- var c = this, b = c.gantt;
- if (c.useTooltip) {
- c.tip = Ext.create("Gnt.Tooltip", {
- gantt : b
- })
- }
- c.callParent([b.el, Ext.apply(a, {
- ddGroup : c.gantt.id + "-task-dd"
- })]);
- c.scroll = false;
- c.isTarget = true;
- c.ignoreSelf = false;
- c.addInvalidHandleClass("sch-resizable-handle");
- c.addInvalidHandleClass("x-resizable-handle");
- c.addInvalidHandleClass("sch-gantt-terminal");
- c.addInvalidHandleClass("sch-gantt-progressbar-handle");
- Ext.dd.ScrollManager.register(c.gantt.el);
- c.gantt.ownerCt.el.appendChild(this.proxy.el);
- c.gantt.on({
- destroy : c.cleanUp,
- scope : c
- })
- },
- useTooltip : true,
- validatorFn : function(a, b, d, c) {
- return true
- },
- validatorFnScope : null,
- cleanUp : function() {
- if (this.tip) {
- this.tip.destroy()
- }
- this.destroy()
- },
- containerScroll : false,
- dropAllowed : "sch-gantt-dragproxy",
- dropNotAllowed : "sch-gantt-dragproxy",
- destroy : function() {
- this.callParent(arguments);
- Ext.dd.ScrollManager.unregister(this.gantt.el)
- },
- autoOffset : function(a, e) {
- var d = this.dragData.repairXY, c = a - d[0], b = e - d[1];
- this.setDelta(c, b)
- },
- setXConstraint : function(c, b, a) {
- this.leftConstraint = c;
- this.rightConstraint = b;
- this.minX = c;
- this.maxX = b;
- if (a) {
- this.setXTicks(this.initPageX, a)
- }
- this.constrainX = true
- },
- setYConstraint : function(a, c, b) {
- this.topConstraint = a;
- this.bottomConstraint = c;
- this.minY = a;
- this.maxY = c;
- if (b) {
- this.setYTicks(this.initPageY, b)
- }
- this.constrainY = true
- },
- constrainTo : function(a, b) {
- this.resetConstraints();
- this.initPageX = a.left;
- this.initPageY = b.top;
- this.setXConstraint(a.left, a.right - (b.right - b.left),
- this.xTickSize);
- this.setYConstraint(b.top - 1, b.top - 1, this.yTickSize)
- },
- onDragOver : function(h, i) {
- var g = this.dragData, f = g.record, d = this.gantt, b = this.proxy.el
- .getX()
- + d.getXOffset(f), a = d.getDateFromXY([b, 0], "round");
- if (!g.hidden) {
- Ext.fly(g.sourceNode).hide();
- g.hidden = true
- }
- if (!a || a - g.start === 0) {
- return
- }
- g.start = a;
- this.valid = this.validatorFn.call(this.validatorFnScope || d, f, a,
- g.duration, h) !== false;
- if (this.tip) {
- var c = f.calculateEndDate(a, f.getDuration(), f.getDurationUnit());
- this.updateTip(f, a, c)
- }
- },
- onStartDrag : function() {
- var a = this.dragData.record;
- if (this.tip) {
- this.tip.enable();
- this.tip.show(Ext.get(this.dragData.sourceNode));
- this.updateTip(a, a.getStartDate(), a.getEndDate())
- }
- this.gantt.fireEvent("taskdragstart", this.gantt, a)
- },
- updateTip : function(b, c, a) {
- if (b.isMilestone() && c - Ext.Date.clearTime(c, true) === 0) {
- c = Sch.util.Date.add(c, Sch.util.Date.MILLI, -1);
- a = Sch.util.Date.add(a, Sch.util.Date.MILLI, -1)
- }
- this.tip.update(c, a, true)
- },
- getDragData : function(i) {
- var h = this.gantt, f = i.getTarget(h.eventSelector);
- if (f && !i.getTarget(".sch-gantt-baseline-item")) {
- var c = Ext.get(f), d = h.resolveTaskRecord(c);
- if (h.fireEvent("beforetaskdrag", h, d, i) === false) {
- return null
- }
- var j = f.cloneNode(true), b = h.getSnapPixelAmount(), a = c
- .getXY();
- j.id = Ext.id();
- if (b <= 1) {
- Ext.fly(j).setStyle("left", 0)
- }
- this.constrainTo(Ext.fly(h.findItemByChild(f)).getRegion(), c
- .getRegion());
- if (b >= 1) {
- this.setXConstraint(this.leftConstraint, this.rightConstraint,
- b)
- }
- return {
- sourceNode : f,
- repairXY : a,
- ddel : j,
- record : d,
- duration : Sch.util.Date.getDurationInMinutes(d.getStartDate(),
- d.getEndDate())
- }
- }
- return null
- },
- afterRepair : function() {
- Ext.fly(this.dragData.sourceNode).show();
- if (this.tip) {
- this.tip.hide()
- }
- this.dragging = false
- },
- getRepairXY : function() {
- this.gantt.fireEvent("afterdnd", this.gantt);
- return this.dragData.repairXY
- },
- onDragDrop : function(g, i) {
- var f = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(i), d = this.dragData, b = this.gantt, a = d.record, h = d.start;
- var c = false;
- if (this.tip) {
- this.tip.disable()
- }
- if (this.valid && h && a.getStartDate() - h !== 0) {
- b.taskStore.on("update", function() {
- c = true
- }, null, {
- single : true
- });
- a.setStartDate(h, true, b.taskStore.skipWeekendsDuringDragDrop);
- if (c) {
- b.fireEvent("taskdrop", b, a);
- if (Ext.isIE9) {
- this.proxy.el.setStyle("visibility", "hidden");
- Ext.Function.defer(this.onValidDrop, 10, this, [f, g, i])
- } else {
- this.onValidDrop(f, g, i)
- }
- }
- }
- if (!c) {
- this.onInvalidDrop(f, g, i)
- }
- b.fireEvent("aftertaskdrop", b, a)
- }
- });
- Ext.define("Gnt.feature.DependencyDragDrop", {
- extend : "Ext.util.Observable",
- constructor : function(b) {
- this.addEvents("beforednd", "dndstart", "drop", "afterdnd");
- var a = b.ganttView;
- Ext.apply(this, {
- el : a.el,
- ddGroup : a.id + "-sch-dependency-dd",
- ganttView : a,
- dependencyStore : a.getDependencyStore()
- });
- this.el.on("mousemove", function() {
- this.setupDragZone();
- this.setupDropZone()
- }, this, {
- single : true
- });
- this.callParent(arguments)
- },
- fromText : "From: <strong>{0}</strong> {1}<br/>",
- toText : "To: <strong>{0}</strong> {1}",
- startText : "Start",
- endText : "End",
- useLineProxy : true,
- terminalSelector : ".sch-gantt-terminal",
- destroy : function() {
- if (this.dragZone) {
- this.dragZone.destroy()
- }
- if (this.dropZone) {
- this.dropZone.destroy()
- }
- if (this.lineProxyEl) {
- this.lineProxyEl.destroy()
- }
- },
- initLineProxy : function(b, a) {
- var c = this.lineProxyEl = this.el.createChild({
- cls : "sch-gantt-connector-proxy"
- });
- c.alignTo(b, a ? "l" : "r");
- Ext.apply(this, {
- containerTop : this.el.getTop(),
- containerLeft : this.el.getLeft(),
- startXY : c.getXY(),
- startScrollLeft : this.el.dom.scrollLeft,
- startScrollTop : this.el.dom.scrollTop
- })
- },
- updateLineProxy : function(m) {
- var a = this.lineProxyEl, j = m[0] - this.startXY[0]
- + this.el.dom.scrollLeft - this.startScrollLeft, i = m[1]
- - this.startXY[1] + this.el.dom.scrollTop - this.startScrollTop, b = Math
- .max(1, Math.sqrt(Math.pow(j, 2) + Math.pow(i, 2)) - 2), h = Math
- .atan2(i, j)
- - (Math.PI / 2), e;
- if (Ext.isIE) {
- var k = Math.cos(h), g = Math.sin(h), l = 'progid:DXImageTransform.Microsoft.Matrix(sizingMethod="auto expand", M11 = '
- + k
- + ", M12 = "
- + (-g)
- + ", M21 = "
- + g
- + ", M22 = "
- + k
- + ")", d, f;
- if (this.el.dom.scrollTop !== this.startScrollTop) {
- d = this.startScrollTop - this.containerTop
- } else {
- d = this.el.dom.scrollTop - this.containerTop
- }
- if (this.el.dom.scrollLeft !== this.startScrollLeft) {
- f = this.startScrollLeft - this.containerLeft
- } else {
- f = this.el.dom.scrollLeft - this.containerLeft
- }
- e = {
- height : b + "px",
- top : Math.min(0, i) + this.startXY[1] + d + (i < 0 ? 2 : 0)
- + "px",
- left : Math.min(0, j) + this.startXY[0] + f + (j < 0 ? 2 : 0)
- + "px",
- filter : l,
- "-ms-filter" : l
- }
- } else {
- var c = "rotate(" + h + "rad)";
- e = {
- height : b + "px",
- "-o-transform" : c,
- "-webkit-transform" : c,
- "-moz-transform" : c,
- transform : c
- }
- }
- a.show().setStyle(e)
- },
- setupDragZone : function() {
- var b = this, a = this.ganttView;
- this.dragZone = Ext.create("Ext.dd.DragZone", this.el, {
- ddGroup : this.ddGroup,
- onStartDrag : function() {
- this.el.addCls("sch-gantt-dep-dd-dragging");
- b.fireEvent("dndstart", b);
- if (b.useLineProxy) {
- var c = this.dragData;
- b.initLineProxy(c.sourceNode, c.isStart)
- }
- },
- getDragData : function(g) {
- var f = g.getTarget(b.terminalSelector);
- if (f) {
- var d = a.resolveTaskRecord(f);
- if (b.fireEvent("beforednd", this, d) === false) {
- return null
- }
- var c = !!f.className.match("sch-gantt-terminal-start"), h = Ext.core.DomHelper
- .createDom({
- cls : "sch-dd-dependency",
- children : [{
- tag : "span",
- cls : "sch-dd-dependency-from",
- html : Ext.String.format(
- b.fromText, d.getName(), c
- ? b.startText
- : b.endText)
- }, {
- tag : "span",
- cls : "sch-dd-dependency-to",
- html : Ext.String.format(b.toText,
- "", "")
- }]
- });
- return {
- fromId : d.getId() || d.internalId,
- isStart : c,
- repairXY : Ext.fly(f).getXY(),
- ddel : h,
- sourceNode : Ext.fly(f).up(a.eventSelector)
- }
- }
- return false
- },
- afterRepair : function() {
- this.el.removeCls("sch-gantt-dep-dd-dragging");
- this.dragging = false;
- b.fireEvent("afterdnd", this)
- },
- onMouseUp : function() {
- this.el.removeCls("sch-gantt-dep-dd-dragging");
- if (b.lineProxyEl) {
- if (Ext.isIE) {
- Ext.destroy(b.lineProxyEl);
- b.lineProxyEl = null
- } else {
- b.lineProxyEl.animate({
- to : {
- height : 0
- },
- duration : 500,
- callback : function() {
- Ext.destroy(b.lineProxyEl);
- b.lineProxyEl = null
- }
- })
- }
- }
- },
- getRepairXY : function() {
- return this.dragData.repairXY
- }
- })
- },
- setupDropZone : function() {
- var b = this, a = this.ganttView;
- this.dropZone = Ext.create("Ext.dd.DropZone", this.el, {
- ddGroup : this.ddGroup,
- getTargetFromEvent : function(c) {
- if (b.useLineProxy) {
- b.updateLineProxy(c.getXY())
- }
- return c.getTarget(b.terminalSelector)
- },
- onNodeEnter : function(h, c, g, f) {
- var d = h.className.match("sch-gantt-terminal-start");
- Ext.fly(h).addCls(d
- ? "sch-gantt-terminal-start-drophover"
- : "sch-gantt-terminal-end-drophover")
- },
- onNodeOut : function(h, c, g, f) {
- var d = h.className.match("sch-gantt-terminal-start");
- Ext.fly(h).removeCls(d
- ? "sch-gantt-terminal-start-drophover"
- : "sch-gantt-terminal-end-drophover")
- },
- onNodeOver : function(k, c, j, i) {
- var d = a.resolveTaskRecord(k), f = d.getId() || d.internalId, g = k.className
- .match("sch-gantt-terminal-start"), h = Ext.String
- .format(b.toText, d.getName(), g
- ? b.startText
- : b.endText);
- c.proxy.el.down(".sch-dd-dependency-to").update(h);
- if (b.dependencyStore.isValidDependency(i.fromId, f)) {
- return this.dropAllowed
- } else {
- return this.dropNotAllowed
- }
- },
- onNodeDrop : function(h, l, i, f) {
- var j, c = true, d = Gnt.model.Dependency.Type, g = a
- .resolveTaskRecord(h), k = g.getId() || g.internalId;
- if (b.lineProxyEl) {
- Ext.destroy(b.lineProxyEl);
- b.lineProxyEl = null
- }
- this.el.removeCls("sch-gantt-dep-dd-dragging");
- if (f.isStart) {
- if (h.className.match("sch-gantt-terminal-start")) {
- j = d.StartToStart
- } else {
- j = d.StartToEnd
- }
- } else {
- if (h.className.match("sch-gantt-terminal-start")) {
- j = d.EndToStart
- } else {
- j = d.EndToEnd
- }
- }
- c = b.dependencyStore.isValidDependency(f.fromId, k);
- if (c) {
- b.fireEvent("drop", this, f.fromId, k, j)
- }
- b.fireEvent("afterdnd", this);
- return c
- }
- })
- }
- });
- Ext.define("Gnt.feature.DragCreator", {
- requires : ["Ext.Template", "Sch.util.DragTracker", "Gnt.Tooltip"],
- constructor : function(a) {
- Ext.apply(this, a || {});
- this.init()
- },
- disabled : false,
- showDragTip : true,
- dragTolerance : 2,
- validatorFn : Ext.emptyFn,
- validatorFnScope : null,
- setDisabled : function(a) {
- this.disabled = a;
- if (this.dragTip) {
- this.dragTip.setDisabled(a)
- }
- },
- getProxy : function() {
- if (!this.proxy) {
- this.proxy = this.template.append(
- this.ganttView.ownerCt.el, {}, true)
- }
- return this.proxy
- },
- onBeforeDragStart : function(f) {
- var c = this.ganttView, b = f.getTarget("." + c.timeCellCls, 2);
- if (b) {
- var a = c.resolveTaskRecord(b);
- var d = c.getDateFromDomEvent(f);
- if (!this.disabled
- && b
- && !a.getStartDate()
- && !a.getEndDate()
- && c.fireEvent("beforedragcreate", c, a, d, f) !== false) {
- f.stopEvent();
- this.taskRecord = a;
- this.originalStart = d;
- this.rowRegion = c.getScheduleRegion(this.taskRecord,
- this.originalStart);
- this.dateConstraints = c.getDateConstraints(
- this.resourceRecord, this.originalStart);
- return true
- }
- }
- return false
- },
- onDragStart : function() {
- var c = this, a = c.ganttView, b = c.getProxy();
- c.start = c.originalStart;
- c.end = c.start;
- c.rowBoundaries = {
- top : c.rowRegion.top,
- bottom : c.rowRegion.bottom
- };
- b.setRegion({
- top : c.rowBoundaries.top,
- right : c.tracker.startXY[0],
- bottom : c.rowBoundaries.bottom,
- left : c.tracker.startXY[0]
- });
- b.show();
- c.ganttView.fireEvent("dragcreatestart", c.ganttView);
- if (c.showDragTip) {
- c.dragTip.update(c.start, c.end, true, this.taskRecord);
- c.dragTip.enable();
- c.dragTip.show(b)
- }
- },
- onDrag : function(g) {
- var d = this, c = d.ganttView, b = d.tracker.getRegion()
- .constrainTo(d.rowRegion), f = c
- .getStartEndDatesFromRegion(b, "round");
- if (!f) {
- return
- }
- d.start = f.start || d.start;
- d.end = f.end || d.end;
- var a = d.dateConstraints;
- if (a) {
- d.end = Sch.util.Date.constrain(d.end, a.start, a.end);
- d.start = Sch.util.Date.constrain(d.start, a.start, a.end)
- }
- d.valid = this.validatorFn.call(d.validatorFnScope || d,
- this.taskRecord, d.start, d.end, g) !== false;
- if (d.showDragTip) {
- d.dragTip.update(d.start, d.end, d.valid, this.taskRecord)
- }
- Ext.apply(b, d.rowBoundaries);
- this.getProxy().setRegion(b)
- },
- onDragEnd : function(a) {
- var b = this.ganttView;
- if (this.showDragTip) {
- this.dragTip.disable()
- }
- if (!this.start || !this.end || (this.end < this.start)) {
- this.valid = false
- }
- if (this.valid) {
- this.taskRecord.setStartEndDate(this.start, this.end);
- b.fireEvent("dragcreateend", b, this.taskRecord, a)
- }
- this.proxy.hide();
- b.fireEvent("afterdragcreate", b)
- },
- init : function() {
- var c = this.ganttView, a = c.el, b = Ext.Function.bind;
- this.lastTime = new Date();
- this.template = this.template
- || Ext
- .create(
- "Ext.Template",
- '<div class="sch-gantt-dragcreator-proxy"></div>',
- {
- compiled : true,
- disableFormats : true
- });
- c.on({
- destroy : this.onGanttDestroy,
- scope : this
- });
- this.tracker = new Sch.util.DragTracker({
- el : a,
- tolerance : this.dragTolerance,
- onBeforeStart : b(this.onBeforeDragStart, this),
- onStart : b(this.onDragStart, this),
- onDrag : b(this.onDrag, this),
- onEnd : b(this.onDragEnd, this)
- });
- if (this.showDragTip) {
- this.dragTip = Ext.create("Gnt.Tooltip", {
- mode : "duration",
- cls : "sch-gantt-dragcreate-tip",
- gantt : c
- })
- }
- },
- onGanttDestroy : function() {
- if (this.dragTip) {
- this.dragTip.destroy()
- }
- if (this.tracker) {
- this.tracker.destroy()
- }
- if (this.proxy) {
- Ext.destroy(this.proxy);
- this.proxy = null
- }
- }
- });
- Ext.define("Gnt.feature.LabelEditor", {
- extend : "Ext.Editor",
- labelPosition : "",
- constructor : function(b, a) {
- this.ganttView = b;
- this.ganttView.on("afterrender", this.onGanttRender, this);
- this.callParent([a])
- },
- edit : function(a) {
- var b = this.ganttView.getElementFromEventRecord(a)
- .up(this.ganttView.eventWrapSelector);
- this.record = a;
- this.startEdit(b.down(this.delegate), this.dataIndex ? a
- .get(this.dataIndex) : "")
- },
- delegate : "",
- dataIndex : "",
- shadow : false,
- completeOnEnter : true,
- cancelOnEsc : true,
- ignoreNoChange : true,
- onGanttRender : function(a) {
- if (!this.field.width) {
- this.autoSize = "width"
- }
- this.on({
- beforestartedit : function(c, b, d) {
- return a.fireEvent("labeledit_beforestartedit",
- a, this.record, d, c)
- },
- beforecomplete : function(c, d, b) {
- return a.fireEvent("labeledit_beforecomplete",
- a, d, b, this.record, c)
- },
- complete : function(c, d, b) {
- this.record.set(this.dataIndex, d);
- a.fireEvent("labeledit_complete", a, d, b,
- this.record, c)
- },
- scope : this
- });
- a.el.on("dblclick", function(c, b) {
- this.edit(a.resolveTaskRecord(b))
- }, this, {
- delegate : this.delegate
- })
- }
- });
- Ext.define("Gnt.feature.ProgressBarResize", {
- requires : ["Ext.ToolTip", "Ext.resizer.Resizer"],
- constructor : function(a) {
- Ext.apply(this, a || {});
- var b = this.gantt;
- b.on({
- destroy : this.cleanUp,
- scope : this
- });
- b.mon(b.el, "mousedown", this.onMouseDown, this, {
- delegate : ".sch-gantt-progressbar-handle"
- });
- this.callParent(arguments)
- },
- useTooltip : true,
- increment : 10,
- onMouseDown : function(d, b) {
- var c = this.gantt, f = c.resolveTaskRecord(b);
- if (c.fireEvent("beforeprogressbarresize", c, f) !== false) {
- var a = Ext.fly(b).prev(".sch-gantt-progress-bar");
- d.stopEvent();
- this.createResizable(a, f, d);
- c.fireEvent("progressbarresizestart", c, f)
- }
- },
- createResizable : function(d, a, h) {
- var c = h.getTarget(), i = d.up(this.gantt.eventSelector), g = i
- .getWidth()
- - 4, b = g * this.increment / 100;
- var f = Ext.create("Ext.resizer.Resizer", {
- target : d,
- taskRecord : a,
- handles : "e",
- minWidth : 0,
- maxWidth : g,
- minHeight : 1,
- widthIncrement : b,
- listeners : {
- resizedrag : this.partialResize,
- resize : this.afterResize,
- scope : this
- }
- });
- f.resizeTracker.onMouseDown(h, f.east.dom);
- i
- .select(".x-resizable-handle, .sch-gantt-terminal, .sch-gantt-progressbar-handle")
- .hide();
- if (this.useTooltip) {
- if (!this.tip) {
- this.tip = Ext.create("Ext.ToolTip", {
- autoHide : false,
- anchor : "b",
- html : "%"
- })
- }
- this.tip.setTarget(d);
- this.tip.show();
- this.tip.body.update(a.getPercentDone() + "%")
- }
- },
- partialResize : function(c, b) {
- var a = Math.round(b * 100 / (c.maxWidth * this.increment))
- * this.increment;
- if (this.tip) {
- this.tip.body.update(a + "%")
- }
- },
- afterResize : function(d, a, b, f) {
- var g = d.taskRecord;
- if (this.tip) {
- this.tip.hide()
- }
- var c = Math.round(a * 100 / (d.maxWidth * this.increment))
- * this.increment;
- d.taskRecord.setPercentDone(c);
- d.destroy();
- this.gantt.fireEvent("afterprogressbarresize", this.gantt, g)
- },
- cleanUp : function() {
- if (this.tip) {
- this.tip.destroy()
- }
- }
- });
- Ext.define("Gnt.feature.TaskResize", {
- constructor : function(a) {
- Ext.apply(this, a);
- var b = this.gantt;
- b.on({
- destroy : this.cleanUp,
- scope : this
- });
- b.mon(b.el, "mousedown", this.onMouseDown, this, {
- delegate : ".sch-resizable-handle"
- });
- this.callParent(arguments)
- },
- showDuration : true,
- useTooltip : true,
- validatorFn : Ext.emptyFn,
- validatorFnScope : null,
- onMouseDown : function(f) {
- var b = this.gantt, a = f.getTarget(b.eventSelector), g = b
- .resolveTaskRecord(a);
- var c = a.className.match("start") ? "west" : "east";
- var d = g.isResizable();
- if (d === false || typeof d === "string" && !a.className.match(d)) {
- return
- }
- if (b.fireEvent("beforetaskresize", b, g, f) === false) {
- return
- }
- f.stopEvent();
- this.createResizable(Ext.get(a), g, f);
- b.fireEvent("taskresizestart", b, g)
- },
- createResizable : function(c, k, j) {
- var m = j.getTarget(), i = this.gantt, a = !!m.className
- .match("sch-resizable-handle-west"), d = i.getSnapPixelAmount(), f = c
- .getWidth(), l = c.up(".x-grid-row").getRegion();
- this.resizable = Ext.create("Ext.resizer.Resizer", {
- startLeft : c.getLeft(),
- startRight : c.getRight(),
- target : c,
- taskRecord : k,
- handles : a ? "w" : "e",
- constrainTo : l,
- minHeight : 1,
- minWidth : d,
- widthIncrement : d,
- listeners : {
- resizedrag : this[a ? "partialWestResize" : "partialEastResize"],
- resize : this.afterResize,
- scope : this
- }
- });
- this.resizable.resizeTracker.onMouseDown(j, this.resizable[a
- ? "west"
- : "east"].dom);
- if (this.useTooltip) {
- if (!this.tip) {
- this.tip = Ext.create("Gnt.Tooltip", {
- mode : this.showDuration ? "duration" : "startend",
- gantt : this.gantt
- })
- }
- var b = k.getStartDate(), h = k.getEndDate();
- this.tip.show(c);
- this.tip.update(b, h, true, k)
- }
- },
- partialEastResize : function(i, f, b, g) {
- var c = this.gantt, a = c.getDateFromXY([
- i.startLeft + Math.min(f, this.resizable.maxWidth), 0],
- "round");
- if (!a || i.end - a === 0) {
- return
- }
- var h = i.taskRecord.getStartDate(), d = this.validatorFn.call(
- this.validatorFnScope || this, i.taskRecord, h, a) !== false;
- i.end = a;
- c.fireEvent("partialtaskresize", c, i.taskRecord, h, a, i.el, g);
- if (this.useTooltip) {
- this.tip.update(h, a, d, i.taskRecord)
- }
- },
- partialWestResize : function(i, f, b, g) {
- var c = this.gantt, h = c.getDateFromXY(
- [i.startRight - Math.min(f, this.resizable.maxWidth), 0],
- "round");
- if (!h || i.start - h === 0) {
- return
- }
- var a = i.taskRecord.getEndDate(), d = this.validatorFn.call(
- this.validatorFnScope || this, i.taskRecord, h, a) !== false;
- i.start = h;
- c.fireEvent("partialtaskresize", c, i.taskRecord, h, a, i.el, g);
- if (this.useTooltip) {
- this.tip.update(h, a, d, i.taskRecord)
- }
- },
- afterResize : function(a, l, i, j) {
- if (this.useTooltip) {
- this.tip.hide()
- }
- var k = a.taskRecord, g = k.getStartDate(), m = k.getEndDate(), c = a.start
- || g, f = a.end || m, d = this.gantt;
- a.destroy();
- if (c
- && f
- && (c - g || f - m)
- && this.validatorFn.call(this.validatorFnScope || this, k, c,
- f, j) !== false) {
- var b = this.gantt.taskStore.skipWeekendsDuringDragDrop;
- if (c - g !== 0) {
- k.setStartDate(c <= f ? c : f, false, b)
- } else {
- k.setEndDate(c <= f ? f : c, false, b)
- }
- } else {
- d.refreshKeepingScroll()
- }
- d.fireEvent("aftertaskresize", d, k)
- },
- cleanUp : function() {
- if (this.tip) {
- this.tip.destroy()
- }
- }
- });
- Ext.define("Gnt.feature.WorkingTime", {
- extend : "Sch.plugin.Zones",
- requires : ["Ext.data.Store", "Sch.model.Range"],
- expandToFitView : true,
- calendar : null,
- init : function(a) {
- if (!this.calendar) {
- Ext.Error
- .raise("Required attribute 'calendar' missed during initialization of 'Gnt.feature.WorkingTime'")
- }
- this.bindCalendar(this.calendar);
- Ext.apply(this, {
- store : new Ext.data.Store({
- model : "Sch.model.Range"
- })
- });
- this.callParent(arguments);
- a.on("viewchange", this.onViewChange, this);
- this.onViewChange()
- },
- bindCalendar : function(b) {
- var a = {
- datachanged : this.refresh,
- update : this.refresh,
- scope : this,
- delay : 1
- };
- if (this.calendar) {
- this.calendar.un(a)
- }
- b.on(a);
- this.calendar = b
- },
- onViewChange : function() {
- var a = Sch.util.Date;
- if (a.compareUnits(this.timeAxis.unit, a.WEEK) > 0) {
- this.setDisabled(true)
- } else {
- this.setDisabled(false);
- this.refresh()
- }
- },
- refresh : function() {
- var a = this.schedulerView;
- this.store.removeAll(true);
- this.store.add(this.calendar.getHolidaysRanges(a.getStart(),
- a.getEnd(), true))
- }
- });
- Ext.define("Gnt.plugin.DependencyEditor", {
- extend : "Ext.form.FormPanel",
- mixins : ["Ext.AbstractPlugin"],
- lockableScope : "normal",
- requires : ["Ext.form.DisplayField", "Ext.form.ComboBox",
- "Ext.form.NumberField", "Gnt.model.Dependency"],
- hideOnBlur : true,
- fromText : "From",
- toText : "To",
- typeText : "Type",
- lagText : "Lag",
- endToStartText : "Finish-To-Start",
- startToStartText : "Start-To-Start",
- endToEndText : "Finish-To-Finish",
- startToEndText : "Start-To-Finish",
- showLag : false,
- border : false,
- height : 150,
- width : 260,
- frame : true,
- labelWidth : 60,
- constrain : false,
- initComponent : function() {
- Ext.apply(this, {
- items : this.buildFields(),
- defaults : {
- width : 240
- },
- floating : true,
- hideMode : "offsets"
- });
- this.callParent(arguments)
- },
- beforeRender : function() {
- this.addCls("sch-gantt-dependencyeditor");
- this.callParent(arguments)
- },
- init : function(a) {
- a.on({
- dependencydblclick : this.onDependencyDblClick,
- destroy : this.destroy,
- scope : this
- });
- a.on("afterrender", this.onGanttRender, this, {
- delay : 50
- });
- this.gantt = a;
- this.taskStore = a.getTaskStore()
- },
- onGanttRender : function() {
- this.render(Ext.getBody());
- this.collapse(Ext.Component.DIRECTION_TOP, true);
- this.hide();
- if (this.hideOnBlur) {
- this.mon(Ext.getBody(), "click", this.onMouseClick, this)
- }
- },
- show : function(a, b) {
- this.dependencyRecord = a;
- this.getForm().loadRecord(a);
- this.fromLabel
- .setValue(this.dependencyRecord.getSourceTask().getName());
- this.toLabel.setValue(this.dependencyRecord.getTargetTask().getName());
- this.callParent([]);
- this.el.setXY(b);
- this.expand(!this.constrain);
- if (this.constrain) {
- this.doConstrain(Ext.util.Region.getRegion(Ext.getBody()))
- }
- },
- buildFields : function() {
- var c = this, d = Gnt.model.Dependency, b = d.Type, a = [
- this.fromLabel = Ext.create("Ext.form.DisplayField", {
- fieldLabel : this.fromText
- }),
- this.toLabel = Ext.create("Ext.form.DisplayField", {
- fieldLabel : this.toText
- }), this.typeField = Ext.create("Ext.form.ComboBox", {
- name : d.prototype.nameField,
- fieldLabel : this.typeText,
- triggerAction : "all",
- queryMode : "local",
- valueField : "value",
- displayField : "text",
- editable : false,
- store : Ext.create("Ext.data.JsonStore", {
- fields : ["text", "value"],
- data : [{
- text : this.endToStartText,
- value : b.EndToStart
- }, {
- text : this.startToStartText,
- value : b.StartToStart
- }, {
- text : this.endToEndText,
- value : b.EndToEnd
- }, {
- text : this.startToEndText,
- value : b.StartToEnd
- }]
- })
- })];
- if (this.showLag) {
- a.push(this.lagField = Ext.create("Ext.form.NumberField", {
- name : d.prototype.lagField,
- fieldLabel : this.lagText
- }))
- }
- return a
- },
- onDependencyDblClick : function(c, a, d, b) {
- if (this.lagField) {
- this.lagField.name = a.lagField
- }
- if (this.typeField) {
- this.typeField.name = a.typeField
- }
- if (a != this.dependencyRecord) {
- this.show(a, d.getXY())
- }
- },
- onMouseClick : function(a) {
- if (this.collapsed || a.within(this.getEl()) || a.getTarget(".x-layer")
- || a.getTarget(".sch-ignore-click")) {
- return
- }
- this.collapse()
- },
- afterCollapse : function() {
- delete this.dependencyRecord;
- this.hide();
- this.callParent(arguments)
- }
- });
- Ext.define("Gnt.plugin.TaskContextMenu", {
- extend : "Ext.menu.Menu",
- mixins : ["Ext.AbstractPlugin"],
- lockableScope : "top",
- requires : ["Gnt.model.Dependency"],
- plain : true,
- triggerEvent : "taskcontextmenu",
- texts : {
- newTaskText : "New task",
- newMilestoneText : "New milestone",
- deleteTask : "Delete task(s)",
- editLeftLabel : "Edit left label",
- editRightLabel : "Edit right label",
- add : "Add...",
- deleteDependency : "Delete dependency...",
- addTaskAbove : "Task above",
- addTaskBelow : "Task below",
- addMilestone : "Milestone",
- addSubtask : "Sub-task",
- addSuccessor : "Successor",
- addPredecessor : "Predecessor"
- },
- grid : null,
- rec : null,
- lastHighlightedItem : null,
- createMenuItems : function() {
- var a = this.texts;
- return [{
- handler : this.deleteTask,
- requiresTask : true,
- scope : this,
- text : a.deleteTask
- }, {
- handler : this.editLeftLabel,
- requiresTask : true,
- scope : this,
- text : a.editLeftLabel
- }, {
- handler : this.editRightLabel,
- requiresTask : true,
- scope : this,
- text : a.editRightLabel
- }, {
- text : a.add,
- menu : {
- plain : true,
- items : [{
- handler : this.addTaskAboveAction,
- requiresTask : true,
- scope : this,
- text : a.addTaskAbove
- }, {
- handler : this.addTaskBelowAction,
- scope : this,
- text : a.addTaskBelow
- }, {
- handler : this.addMilestone,
- requiresTask : true,
- scope : this,
- text : a.addMilestone
- }, {
- handler : this.addSubtask,
- requiresTask : true,
- scope : this,
- text : a.addSubtask
- }, {
- handler : this.addSuccessor,
- requiresTask : true,
- scope : this,
- text : a.addSuccessor
- }, {
- handler : this.addPredecessor,
- requiresTask : true,
- scope : this,
- text : a.addPredecessor
- }]
- }
- }, {
- text : a.deleteDependency,
- requiresTask : true,
- isDependenciesMenu : true,
- menu : {
- plain : true,
- listeners : {
- beforeshow : this.populateDependencyMenu,
- mouseover : this.onDependencyMouseOver,
- mouseleave : this.onDependencyMouseOut,
- scope : this
- }
- }
- }]
- },
- buildMenuItems : function() {
- this.items = this.createMenuItems()
- },
- initComponent : function() {
- this.buildMenuItems();
- this.callParent(arguments)
- },
- init : function(b) {
- b.on("destroy", this.cleanUp, this);
- var a = b.getSchedulingView(), c = b.lockedGrid.getView();
- if (this.triggerEvent === "itemcontextmenu") {
- c.on("itemcontextmenu", this.onItemContextMenu, this);
- a.on("itemcontextmenu", this.onItemContextMenu, this)
- }
- a.on("taskcontextmenu", this.onTaskContextMenu, this);
- a.on("containercontextmenu", this.onContainerContextMenu, this);
- c.on("containercontextmenu", this.onContainerContextMenu, this);
- this.grid = b
- },
- populateDependencyMenu : function(f) {
- var d = this.grid, b = d.getTaskStore(), e = this.rec
- .getAllDependencies(), a = d.dependencyStore;
- f.removeAll();
- if (e.length === 0) {
- return false
- }
- var c = this.rec.getId() || this.rec.internalId;
- Ext.each(e, function(i) {
- var h = i.getSourceId(), g = b.getById(h == c ? i
- .getTargetId() : h);
- if (g) {
- f.add({
- depId : i.internalId,
- text : Ext.util.Format.ellipsis(
- g.getName(), 30),
- scope : this,
- handler : function(k) {
- var j;
- a.each(function(l) {
- if (l.internalId == k.depId) {
- j = l;
- return false
- }
- });
- a.remove(j)
- }
- })
- }
- }, this)
- },
- onDependencyMouseOver : function(d, a, b) {
- if (a) {
- var c = this.grid.getSchedulingView();
- if (this.lastHighlightedItem) {
- c.unhighlightDependency(this.lastHighlightedItem.depId)
- }
- this.lastHighlightedItem = a;
- c.highlightDependency(a.depId)
- }
- },
- onDependencyMouseOut : function(b, a) {
- if (this.lastHighlightedItem) {
- this.grid.getSchedulingView()
- .unhighlightDependency(this.lastHighlightedItem.depId)
- }
- },
- cleanUp : function() {
- this.destroy()
- },
- onTaskContextMenu : function(b, a, c) {
- this.activateMenu(a, c)
- },
- onItemContextMenu : function(b, a, d, c, f) {
- this.activateMenu(a, f)
- },
- onContainerContextMenu : function(a, b) {
- this.activateMenu(null, b)
- },
- activateMenu : function(b, a) {
- if (this.grid.isReadOnly()) {
- return
- }
- a.stopEvent();
- this.rec = b;
- this.configureMenuItems();
- this.showAt(a.getXY())
- },
- configureMenuItems : function() {
- var b = this.query("[requiresTask]");
- var c = this.rec;
- Ext.each(b, function(d) {
- d.setDisabled(!c)
- });
- var a = this.query("[isDependenciesMenu]")[0];
- if (c && a) {
- a.setDisabled(!c.getAllDependencies().length)
- }
- },
- copyTask : function(c) {
- var b = this.grid.getTaskStore().model;
- var a = new b({
- leaf : true
- });
- a.setPercentDone(0);
- a.setName(this.texts.newTaskText);
- a.set(a.startDateField, (c && c.getStartDate()) || null);
- a.set(a.endDateField, (c && c.getEndDate()) || null);
- a.set(a.durationField, (c && c.getDuration()) || null);
- a.set(a.durationUnitField, (c && c.getDurationUnit()) || "d");
- return a
- },
- addTaskAbove : function(a) {
- var b = this.rec;
- if (b) {
- b.addTaskAbove(a)
- } else {
- this.grid.taskStore.getRootNode().appendChild(a)
- }
- },
- addTaskBelow : function(a) {
- var b = this.rec;
- if (b) {
- b.addTaskBelow(a)
- } else {
- this.grid.taskStore.getRootNode().appendChild(a)
- }
- },
- deleteTask : function() {
- var a = this.grid.getSelectionModel().selected;
- this.grid.taskStore.remove(a.items)
- },
- editLeftLabel : function() {
- this.grid.getSchedulingView().editLeftLabel(this.rec)
- },
- editRightLabel : function() {
- this.grid.getSchedulingView().editRightLabel(this.rec)
- },
- addTaskAboveAction : function() {
- this.addTaskAbove(this.copyTask(this.rec))
- },
- addTaskBelowAction : function() {
- this.addTaskBelow(this.copyTask(this.rec))
- },
- addSubtask : function() {
- var a = this.rec;
- a.addSubtask(this.copyTask(a))
- },
- addSuccessor : function() {
- var a = this.rec;
- a.addSuccessor(this.copyTask(a))
- },
- addPredecessor : function() {
- var a = this.rec;
- a.addPredecessor(this.copyTask(a))
- },
- addMilestone : function() {
- var b = this.rec, a = this.copyTask(b);
- b.addTaskBelow(a);
- a.setStartEndDate(b.getEndDate(), b.getEndDate())
- }
- });
- Ext.define("Gnt.plugin.Export", {
- extend : "Sch.plugin.PdfExport",
- alternateClassName : "Gnt.plugin.PdfExport",
- showExportDialog : function() {
- this.exportDialogConfig.scrollerDisabled = true;
- this.callParent(arguments)
- },
- getExportJsonHtml : function(d, g) {
- var b = this.scheduler.getSchedulingView(), c = b.dependencyView, a = c.painter
- .getDependencyTplData(b.dependencyStore.getRange()), e = c.lineTpl
- .apply(a), f = {
- dependencies : e,
- rowsAmount : d.rowsAmount,
- columnsAmountNormal : d.columnsAmountNormal,
- columnsAmountLocked : d.columnsAmountLocked,
- timeColumnWidth : d.timeColumnWidth,
- lockedGridWidth : d.lockedGridWidth,
- rowHeight : d.rowHeight
- };
- d.panelHTML = f;
- return this.callParent(arguments)
- },
- resizePanelHTML : function(e) {
- var f = this.callParent(arguments), b = f
- .select(".sch-dependencyview-ct").first(), d = e.k
- * e.rowsAmount * e.rowHeight, c = e.i * e.timeColumnWidth
- * (e.i === 1 ? e.columnsAmountLocked : e.columnsAmountNormal);
- b.dom.innerHTML = e.dependencies;
- b.applyStyles({
- top : -d + "px",
- left : -c + "px"
- });
- var a = f.select(".x-splitter").first();
- a.setHeight("100%");
- return f
- }
- });
- Ext.define("Gnt.plugin.Printable", {
- extend : "Sch.plugin.Printable",
- getGridContent : function(e) {
- var a = this.callParent(arguments), j = e.getSchedulingView(), h = j.dependencyView, n = h.painter
- .getDependencyTplData(j.dependencyStore.getRange()), d = h.lineTpl
- .apply(n), m = a.normalRows;
- if (Ext.select(".sch-gantt-critical-chain").first()) {
- var b = Ext.DomHelper.createDom({
- tag : "div",
- html : d
- });
- b = Ext.get(b);
- var p = Ext.DomHelper.createDom({
- tag : "div",
- html : m
- });
- p = Ext.get(p);
- var q = j.getCriticalPaths(), c = j.dependencyStore, o, g, f, k;
- Ext.each(q, function(i) {
- for (g = 0, f = i.length; g < f; g++) {
- o = i[g];
- this.highlightTask(o, e, p);
- if (g < (f - 1)) {
- k = c.getAt(c.findBy(function(l) {
- return l.getTargetId() === (o.getId() || o.internalId)
- && l.getSourceId() === (i[g + 1].getId() || i[g
- + 1].internalId)
- }));
- this.highlightDependency(k, b, h)
- }
- }
- }, this);
- m = p.getHTML();
- d = b.getHTML()
- }
- a.normalRows = d + m;
- return a
- },
- highlightTask : function(b, a, e) {
- var d = a.getSchedulingView().getElementFromEventRecord(b), c = d.id;
- if (d) {
- e.select("#" + c).first().parent("tr")
- .addCls("sch-gantt-task-highlighted")
- }
- },
- highlightDependency : function(c, b, a) {
- var d = c instanceof Ext.data.Model ? c.internalId : c;
- return b.select(".sch-dep-" + d).addCls(a.selectedCls)
- }
- });
- Ext.define("Gnt.view.DependencyPainter", {
- requires : ["Ext.util.Region"],
- constructor : function(a) {
- a = a || {};
- Ext.apply(this, a, {
- xOffset : 8,
- yOffset : 7,
- midRowOffset : 6,
- arrowOffset : 8
- })
- },
- getTaskBox : function(q) {
- var h = Sch.util.Date, j = q.getStartDate(), p = q.getEndDate(), m = this.ganttView, d = m
- .getStart(), c = m.getEnd();
- if (!q.isVisible() || !j || !p || !h.intersectSpans(j, p, d, c)) {
- return null
- }
- var e, l = this.taskStore.buffered, b = m.getXYFromDate(h.max(j, d))[0], r = m
- .getXYFromDate(h.min(p, c))[0], a = m.getNodeByRecord(q);
- if (a || l) {
- var t = m.getXOffset(q), n, i, v = q.isMilestone(), u = true;
- if (b > t) {
- b -= t
- }
- r += t - 1;
- if (!v && Ext.isIE) {
- if ((Ext.isIE7 || Ext.isIE6) && !Ext.isIEQuirks) {
- r += 5;
- b -= 2
- } else {
- if ((Ext.isIE6 || Ext.isIE7 || Ext.isIE8) && Ext.isIEQuirks) {
- r += 1;
- b -= 2
- }
- }
- }
- var g = m.el;
- var k = g.getScroll().top;
- if (a) {
- var s = m.getEventNodeByRecord(q);
- if (v) {
- e = Ext.fly(a).getOffsetsTo(g);
- n = e[1] + k;
- i = n + Ext.fly(a).getHeight()
- } else {
- e = Ext.fly(s).getOffsetsTo(g);
- n = e[1] + k;
- i = n + Ext.fly(s).getHeight()
- }
- } else {
- var f = m.store.first();
- var o = m.all.elements;
- if (!f) {
- return null
- }
- if (q.isAbove(f)) {
- a = o[0];
- e = Ext.fly(a).getOffsetsTo(g);
- e[1] -= m.rowHeight
- } else {
- a = o[o.length - 1];
- e = Ext.fly(a).getOffsetsTo(g);
- e[1] += m.rowHeight
- }
- n = e[1] + k;
- i = n + this.rowHeight;
- u = false
- }
- return {
- top : n,
- right : r,
- bottom : i,
- left : b,
- rendered : u
- }
- }
- },
- getRenderData : function(f) {
- var e = f.getSourceTask(), c = f.getTargetTask();
- if (!e || !c) {
- return null
- }
- var a = this.getTaskBox(e);
- var d = this.getTaskBox(c);
- if (this.taskStore.buffered && a && !a.rendered && d && !d.rendered) {
- var g = this.ganttView.store.first();
- var b = this.ganttView.store.last();
- if ((e.isAbove(g) && c.isAbove(g))
- || (b.isAbove(e) && b.isAbove(c))) {
- return null
- }
- }
- return {
- fromBox : a,
- toBox : d
- }
- },
- getDependencyTplData : function(q) {
- var n = this, j = n.taskStore;
- if (!Ext.isArray(q)) {
- q = [q]
- }
- if (q.length === 0 || j.getCount() <= 0) {
- return
- }
- var b = [], a = Gnt.model.Dependency.Type, o = n.ganttView, p, k, g, m, h, c;
- for (var f = 0, d = q.length; f < d; f++) {
- c = q[f];
- var e = this.getRenderData(c);
- if (e) {
- m = e.fromBox;
- h = e.toBox;
- if (m && h) {
- switch (c.getType()) {
- case a.StartToEnd :
- p = n.getStartToEndCoordinates(m, h, c);
- break;
- case a.StartToStart :
- p = n.getStartToStartCoordinates(m, h, c);
- break;
- case a.EndToStart :
- p = n.getEndToStartCoordinates(m, h, c);
- break;
- case a.EndToEnd :
- p = n.getEndToEndCoordinates(m, h, c);
- break;
- default :
- throw "Invalid dependency type: " + c.getType()
- }
- if (p) {
- b.push({
- lineCoordinates : p,
- id : c.internalId,
- cls : c.getCls()
- })
- }
- }
- }
- }
- return b
- },
- getStartToStartCoordinates : function(e, d, c) {
- var b = e.left, g = e.top - 1 + ((e.bottom - e.top) / 2), a = d.left, f = d.top
- - 1 + ((d.bottom - d.top) / 2), h = e.top < d.top
- ? (f - this.yOffset - this.midRowOffset)
- : (f + this.yOffset + this.midRowOffset), i = this.xOffset
- + this.arrowOffset;
- if (b > (a + this.xOffset)) {
- i += (b - a)
- }
- return [{
- x1 : b,
- y1 : g,
- x2 : b - i,
- y2 : g
- }, {
- x1 : b - i,
- y1 : g,
- x2 : b - i,
- y2 : f
- }, {
- x1 : b - i,
- y1 : f,
- x2 : a - this.arrowOffset,
- y2 : f
- }]
- },
- getStartToEndCoordinates : function(g, f, e) {
- var c = g.left, j = g.top - 1 + ((g.bottom - g.top) / 2), a = f.right, h = f.top
- - 1 + ((f.bottom - f.top) / 2), k = g.top < f.top
- ? (h - this.yOffset - this.midRowOffset)
- : (h + this.yOffset + this.midRowOffset), i, b;
- if (a > (c + this.xOffset - this.arrowOffset)
- || Math.abs(a - c) < (2 * (this.xOffset + this.arrowOffset))) {
- b = c - this.xOffset - this.arrowOffset;
- var d = a + this.xOffset + this.arrowOffset;
- i = [{
- x1 : c,
- y1 : j,
- x2 : b,
- y2 : j
- }, {
- x1 : b,
- y1 : j,
- x2 : b,
- y2 : k
- }, {
- x1 : b,
- y1 : k,
- x2 : d,
- y2 : k
- }, {
- x1 : d,
- y1 : k,
- x2 : d,
- y2 : h
- }, {
- x1 : d,
- y1 : h,
- x2 : a + this.arrowOffset,
- y2 : h
- }]
- } else {
- b = c - this.xOffset - this.arrowOffset;
- i = [{
- x1 : c,
- y1 : j,
- x2 : b,
- y2 : j
- }, {
- x1 : b,
- y1 : j,
- x2 : b,
- y2 : h
- }, {
- x1 : b,
- y1 : h,
- x2 : a + this.arrowOffset,
- y2 : h
- }]
- }
- return i
- },
- getEndToStartCoordinates : function(g, f, e) {
- var c = g.right, j = g.top - 1 + ((g.bottom - g.top) / 2), a = f.left, h = f.top
- - 1 + ((f.bottom - f.top) / 2), k = g.top < f.top
- ? (h - this.yOffset - this.midRowOffset)
- : (h + this.yOffset + this.midRowOffset), i, b;
- if (a >= (c - 6) && h > j) {
- b = Math.max(c - 6, a) + this.xOffset - 2;
- h = f.top
- + (e.getTargetTask().isMilestone()
- ? this.rowHeight * 0.18
- : 0);
- i = [{
- x1 : c,
- y1 : j,
- x2 : b,
- y2 : j
- }, {
- x1 : b,
- y1 : j,
- x2 : b,
- y2 : h - this.arrowOffset
- }]
- } else {
- b = c + this.xOffset + this.arrowOffset;
- var d = a - this.xOffset - this.arrowOffset;
- if (h > j || a < (c + 2 * this.arrowOffset)) {
- i = [{
- x1 : c,
- y1 : j,
- x2 : b,
- y2 : j
- }, {
- x1 : b,
- y1 : j,
- x2 : b,
- y2 : k
- }, {
- x1 : b,
- y1 : k,
- x2 : d,
- y2 : k
- }, {
- x1 : d,
- y1 : k,
- x2 : d,
- y2 : h
- }, {
- x1 : d,
- y1 : h,
- x2 : a - this.arrowOffset,
- y2 : h
- }]
- } else {
- i = [{
- x1 : c,
- y1 : j,
- x2 : d,
- y2 : j
- }, {
- x1 : d,
- y1 : j,
- x2 : d,
- y2 : h
- }, {
- x1 : d,
- y1 : h,
- x2 : a - this.arrowOffset,
- y2 : h
- }]
- }
- }
- return i
- },
- getEndToEndCoordinates : function(a, c, e) {
- var d = a.right, g = a.top - 1 + ((a.bottom - a.top) / 2), b = c.right
- + this.arrowOffset, f = c.top - 1 + ((c.bottom - c.top) / 2), h = b
- + this.xOffset + this.arrowOffset;
- if (d > (b + this.xOffset)) {
- h += d - b
- }
- return [{
- x1 : d,
- y1 : g,
- x2 : h,
- y2 : g
- }, {
- x1 : h,
- y1 : g,
- x2 : h,
- y2 : f
- }, {
- x1 : h,
- y1 : f,
- x2 : b,
- y2 : f
- }]
- }
- });
- Ext.define("Gnt.view.Dependency", {
- extend : "Ext.util.Observable",
- requires : ["Gnt.feature.DependencyDragDrop", "Gnt.view.DependencyPainter"],
- containerEl : null,
- ganttView : null,
- painter : null,
- taskStore : null,
- store : null,
- dnd : null,
- lineTpl : null,
- enableDependencyDragDrop : true,
- renderAllDepsBuffered : false,
- dependencyCls : "sch-dependency",
- selectedCls : "sch-dependency-selected",
- dependencyPainterClass : "Gnt.view.DependencyPainter",
- constructor : function(a) {
- this.callParent(arguments);
- var b = this.ganttView;
- b.on({
- refresh : this.renderAllDependenciesBuffered,
- scope : this
- });
- this.bindTaskStore(b.getTaskStore());
- this.bindDependencyStore(a.store);
- if (!this.lineTpl) {
- this.lineTpl = Ext
- .create(
- "Ext.XTemplate",
- '<tpl for=".">'
- + Ext.String
- .format(
- '<tpl for="lineCoordinates"><div class="{0} {lineCls} sch-dep-{parent.id} {0}-line {[this.getSuffixedCls(parent.cls, "-line")]}" style="left:{[Math.min(values.x1, values.x2)]}px;top:{[Math.min(values.y1, values.y2)]}px;width:{[Math.abs(values.x1-values.x2)'
- + (!Ext.isGecko
- && Ext.isBorderBox
- ? "+2"
- : "")
- + "]}px;height:{[Math.abs(values.y1-values.y2)"
- + (!Ext.isGecko
- && Ext.isBorderBox
- ? "+2"
- : "")
- + ']}px"></div></tpl><div style="left:{[values.lineCoordinates[values.lineCoordinates.length - 1].x2]}px;top:{[values.lineCoordinates[values.lineCoordinates.length - 1].y2]}px" class="{0}-arrow-ct {0} sch-dep-{id} {[this.getSuffixedCls(values.cls, "-arrow-ct")]}"><img src="'
- + Ext.BLANK_IMAGE_URL
- + '" class="{0}-arrow {0}-arrow-{[this.getArrowDirection(values.lineCoordinates)]} {[this.getSuffixedCls(values.cls, "-arrow")]}" /></div>',
- this.dependencyCls)
- + "</tpl>", {
- compiled : true,
- disableFormats : true,
- getArrowDirection : function(d) {
- var c = d[d.length - 1];
- if (c.y2 < c.y1) {
- return "up"
- }
- if (c.x1 === c.x2) {
- return "down"
- } else {
- if (c.x1 > c.x2) {
- return "left"
- } else {
- return "right"
- }
- }
- },
- getSuffixedCls : function(c, d) {
- if (c && c.indexOf(" ") != -1) {
- return c.replace(/^\s*(.*)\s*$/, "$1")
- .split(/\s+/).join(d + " ")
- + d
- } else {
- return c + d
- }
- }
- })
- }
- this.painter = Ext.create(this.dependencyPainterClass, Ext.apply({
- rowHeight : b.rowHeight,
- taskStore : this.taskStore,
- view : b
- }, a));
- this.addEvents("beforednd", "dndstart", "drop", "afterdnd",
- "beforecascade", "cascade", "dependencydblclick", "refresh");
- if (this.enableDependencyDragDrop) {
- this.dnd = Ext.create("Gnt.feature.DependencyDragDrop", {
- ganttView : this.ganttView
- });
- this.dnd.on("drop", this.onDependencyDrop, this);
- this.relayEvents(this.dnd, ["beforednd", "dndstart", "afterdnd",
- "drop"])
- }
- this.containerEl = this.containerEl.createChild({
- cls : "sch-dependencyview-ct"
- });
- this.ganttView.mon(this.containerEl, "dblclick",
- this.onDependencyDblClick, this, {
- delegate : "." + this.dependencyCls
- });
- if (b.rendered) {
- this.renderAllDependenciesBuffered()
- }
- },
- bindDependencyStore : function(a) {
- this.depStoreListeners = {
- refresh : this.renderAllDependenciesBuffered,
- load : this.renderAllDependenciesBuffered,
- add : this.onDependencyAdd,
- update : this.onDependencyUpdate,
- remove : this.onDependencyDelete,
- scope : this
- };
- a.on(this.depStoreListeners);
- this.store = a
- },
- unBindDependencyStore : function() {
- if (this.depStoreListeners) {
- this.store.un(this.depStoreListeners)
- }
- },
- bindTaskStore : function(a) {
- var b = this.ganttView;
- this.taskStoreListeners = {
- cascade : this.onTaskStoreCascade,
- "root-fill-start" : this.onRootFillStart,
- remove : this.renderAllDependenciesBuffered,
- insert : this.renderAllDependenciesBuffered,
- append : this.renderAllDependenciesBuffered,
- move : this.renderAllDependenciesBuffered,
- update : this.onTaskUpdated,
- scope : this
- };
- if (b.animate) {
- this.ganttViewListeners = {
- afterexpand : this.renderAllDependenciesBuffered,
- aftercollapse : this.renderAllDependenciesBuffered,
- scope : this
- };
- b.on(this.ganttViewListeners)
- } else {
- Ext.apply(this.taskStoreListeners, {
- expand : this.renderAllDependenciesBuffered,
- collapse : this.renderAllDependenciesBuffered
- })
- }
- a.on(this.taskStoreListeners);
- this.taskStore = a
- },
- onTaskStoreCascade : function(a, b) {
- if (b && b.nbrAffected > 0) {
- this.renderAllDependenciesBuffered()
- }
- },
- unBindTaskStore : function(a) {
- a = a || this.taskStore;
- if (!a) {
- return
- }
- if (this.ganttViewListeners) {
- this.ganttView.un(this.ganttViewListeners)
- }
- a.un(this.taskStoreListeners)
- },
- onRootFillStart : function() {
- var a = this.taskStore;
- this.unBindTaskStore(a);
- this.taskStore.on("root-fill-end", function() {
- this.bindTaskStore(a)
- }, this, {
- single : true
- })
- },
- onDependencyDblClick : function(b, a) {
- var c = this.getRecordForDependencyEl(a);
- this.fireEvent("dependencydblclick", this, c, b, a)
- },
- highlightDependency : function(a) {
- if (!(a instanceof Ext.data.Model)) {
- a = this.getDependencyRecordByInternalId(a)
- }
- this.getElementsForDependency(a).addCls(this.selectedCls)
- },
- unhighlightDependency : function(a) {
- if (!(a instanceof Ext.data.Model)) {
- a = this.getDependencyRecordByInternalId(a)
- }
- this.getElementsForDependency(a).removeCls(this.selectedCls)
- },
- getElementsForDependency : function(a) {
- var b = a instanceof Ext.data.Model ? a.internalId : a;
- return this.containerEl.select(".sch-dep-" + b)
- },
- depRe : new RegExp("sch-dep-([^\\s]+)"),
- getDependencyRecordByInternalId : function(d) {
- var c, b, a;
- for (b = 0, a = this.store.getCount(); b < a; b++) {
- c = this.store.getAt(b);
- if (c.internalId == d) {
- return c
- }
- }
- return null
- },
- getRecordForDependencyEl : function(c) {
- var a = c.className.match(this.depRe), d = null;
- if (a && a[1]) {
- var b = a[1];
- d = this.getDependencyRecordByInternalId(b)
- }
- return d
- },
- renderAllDependenciesBuffered : function() {
- var a = this;
- this.containerEl.update("");
- setTimeout(function() {
- if (!a.ganttView.isDestroyed) {
- a.renderAllDependencies()
- }
- }, 0)
- },
- renderAllDependencies : function() {
- if (!this.containerEl.dom) {
- return
- }
- this.getDependencyElements().remove();
- this.renderDependencies(this.store.data.items);
- this.fireEvent("refresh", this)
- },
- getDependencyElements : function() {
- return this.containerEl.select("." + this.dependencyCls)
- },
- renderDependencies : function(b) {
- if (b) {
- var a = this.painter.getDependencyTplData(b);
- this.lineTpl[Ext.isIE ? "insertFirst" : "append"](this.containerEl,
- a)
- }
- },
- renderTaskDependencies : function(d) {
- var c = [];
- if (!Ext.isArray(d)) {
- d = [d]
- }
- for (var a = 0, b = d.length; a < b; a++) {
- c = c.concat(d[a].getAllDependencies())
- }
- this.renderDependencies(c)
- },
- onDependencyUpdate : function(b, a) {
- this.removeDependencyElements(a, false);
- this.renderDependencies(a)
- },
- onDependencyAdd : function(a, b) {
- this.renderDependencies(b)
- },
- removeDependencyElements : function(a, b) {
- if (b !== false) {
- this.getElementsForDependency(a).fadeOut({
- remove : true
- })
- } else {
- this.getElementsForDependency(a).remove()
- }
- },
- onDependencyDelete : function(b, a) {
- this.removeDependencyElements(a)
- },
- dimEventDependencies : function(a) {
- this.containerEl.select(this.depRe + a).setOpacity(0.2)
- },
- clearSelectedDependencies : function() {
- this.containerEl.select("." + this.selectedCls)
- .removeCls(this.selectedCls)
- },
- onTaskUpdated : function(c, b, a) {
- if (!this.taskStore.cascading
- && a != Ext.data.Model.COMMIT
- && (!b.previous || b.startDateField in b.previous || b.endDateField in b.previous)) {
- this.updateDependencies(b)
- }
- },
- updateDependencies : function(b) {
- if (!Ext.isArray(b)) {
- b = [b]
- }
- var a = this;
- Ext.each(b, function(c) {
- Ext.each(c.getAllDependencies(), function(d) {
- a.removeDependencyElements(d, false)
- })
- });
- this.renderTaskDependencies(b)
- },
- onNewDependencyCreated : function() {
- },
- onDependencyDrop : function(f, d, b, e) {
- var c = this.store;
- var a = new c.model({
- fromTask : d,
- toTask : b,
- type : e
- });
- if (c.isValidDependency(a) && this.onNewDependencyCreated(a) !== false) {
- c.add(a)
- }
- },
- destroy : function() {
- if (this.dnd) {
- this.dnd.destroy()
- }
- this.unBindTaskStore();
- this.unBindDependencyStore()
- }
- });
- Ext.define("Gnt.view.Gantt", {
- extend : "Sch.view.TimelineTreeView",
- alias : ["widget.ganttview"],
- requires : ["Gnt.view.Dependency", "Gnt.model.Task", "Gnt.template.Task",
- "Gnt.template.ParentTask", "Gnt.template.Milestone",
- "Gnt.feature.TaskDragDrop", "Gnt.feature.ProgressBarResize",
- "Gnt.feature.TaskResize", "Sch.view.Horizontal"],
- uses : ["Gnt.feature.LabelEditor", "Gnt.feature.DragCreator"],
- _cmpCls : "sch-ganttview",
- rowHeight : 22,
- barMargin : 4,
- scheduledEventName : "task",
- trackOver : false,
- toggleOnDblClick : false,
- milestoneOffset : 8,
- parentTaskOffset : 6,
- eventSelector : ".sch-gantt-item",
- eventWrapSelector : ".sch-event-wrap",
- progressBarResizer : null,
- taskResizer : null,
- taskDragDrop : null,
- dragCreator : null,
- dependencyView : null,
- resizeConfig : null,
- createConfig : null,
- dragDropConfig : null,
- progressBarResizeConfig : null,
- dependencyViewConfig : null,
- constructor : function(a) {
- var b = a.panel._top;
- Ext.apply(this, {
- taskStore : b.taskStore,
- dependencyStore : b.dependencyStore,
- enableDependencyDragDrop : b.enableDependencyDragDrop,
- enableTaskDragDrop : b.enableTaskDragDrop,
- enableProgressBarResize : b.enableProgressBarResize,
- enableDragCreation : b.enableDragCreation,
- allowParentTaskMove : b.allowParentTaskMove,
- toggleParentTasksOnClick : b.toggleParentTasksOnClick,
- resizeHandles : b.resizeHandles,
- enableBaseline : b.baselineVisible || b.enableBaseline,
- leftLabelField : b.leftLabelField,
- rightLabelField : b.rightLabelField,
- eventTemplate : b.eventTemplate,
- parentEventTemplate : b.parentEventTemplate,
- milestoneTemplate : b.milestoneTemplate,
- resizeConfig : b.resizeConfig,
- createConfig : b.createConfig,
- dragDropConfig : b.dragDropConfig,
- progressBarResizeConfig : b.progressBarResizeConfig
- });
- this.addEvents("taskclick", "taskdblclick", "taskcontextmenu",
- "beforetaskresize", "taskresizestart", "partialtaskresize",
- "aftertaskresize", "beforeprogressbarresize",
- "progressbarresizestart", "afterprogressbarresize",
- "beforetaskdrag", "taskdragstart", "taskdrop", "aftertaskdrop",
- "labeledit_beforestartedit", "labeledit_beforecomplete",
- "labeledit_complete", "beforedependencydrag",
- "dependencydragstart", "dependencydrop",
- "afterdependencydragdrop", "beforedragcreate",
- "dragcreatestart", "dragcreateend", "afterdragcreate");
- this.callParent(arguments)
- },
- initComponent : function() {
- this.configureLabels();
- this.setupGanttEvents();
- this.callParent(arguments);
- this.setupTemplates()
- },
- getDependencyStore : function() {
- return this.dependencyStore
- },
- configureFeatures : function() {
- if (this.enableProgressBarResize !== false) {
- this.progressBarResizer = Ext.create(
- "Gnt.feature.ProgressBarResize", Ext.apply({
- gantt : this
- }, this.progressBarResizeConfig || {}));
- this.on({
- beforeprogressbarresize : this.onBeforeTaskProgressBarResize,
- progressbarresizestart : this.onTaskProgressBarResizeStart,
- afterprogressbarresize : this.onTaskProgressBarResizeEnd,
- scope : this
- })
- }
- if (this.resizeHandles !== "none") {
- this.taskResizer = Ext.create("Gnt.feature.TaskResize", Ext.apply({
- gantt : this,
- validatorFn : this.resizeValidatorFn
- || Ext.emptyFn,
- validatorFnScope : this.validatorFnScope
- || this
- }, this.resizeConfig || {}));
- this.on({
- beforedragcreate : this.onBeforeDragCreate,
- beforetaskresize : this.onBeforeTaskResize,
- taskresizestart : this.onTaskResizeStart,
- aftertaskresize : this.onTaskResizeEnd,
- scope : this
- })
- }
- if (this.enableTaskDragDrop) {
- this.taskDragDrop = Ext.create("Gnt.feature.TaskDragDrop", Ext
- .apply({
- gantt : this,
- validatorFn : this.dndValidatorFn
- || Ext.emptyFn,
- validatorFnScope : this.validatorFnScope
- || this
- }, this.dragDropConfig));
- this.on({
- beforetaskdrag : this.onBeforeTaskDrag,
- taskdragstart : this.onDragDropStart,
- aftertaskdrop : this.onDragDropEnd,
- scope : this
- })
- }
- if (this.enableDragCreation) {
- this.dragCreator = Ext.create("Gnt.feature.DragCreator", Ext.apply(
- {
- ganttView : this,
- validatorFn : this.createValidatorFn
- || Ext.emptyFn,
- validatorFnScope : this.validatorFnScope
- || this
- }, this.createConfig))
- }
- },
- prepareData : function(d, a, b) {
- var c = this, e = {}, f = c.gridDataColumns || c.getGridColumns();
- e[f[0].id] = this.renderTask(b);
- return e
- },
- renderTask : function(k) {
- var l = k.getStartDate(), n = this.timeAxis, s = Sch.util.Date, b = {}, A = "", h = n
- .getStart(), g = n.getEnd(), C = k.isMilestone(), x = k
- .isLeaf(), o, q, u;
- if (l) {
- var v = k.getEndDate()
- || Sch.util.Date.add(l, Sch.util.Date.DAY, 1), e = Sch.util.Date
- .intersectSpans(l, v, h, g);
- if (e) {
- u = v > g;
- q = s.betweenLesser(l, h, g);
- var z = Math.floor(this.getXYFromDate(q ? l : h)[0]), d = Math
- .floor(this.getXYFromDate(u ? g : v)[0]), f = C ? 0 : d
- - z;
- if (!C && !x) {
- if (u) {
- f += this.parentTaskOffset
- } else {
- f += 2 * this.parentTaskOffset
- }
- }
- b = {
- id : k.internalId,
- leftOffset : C ? (d || z) : z,
- width : Math.max(1, f),
- percentDone : Math.min(k.getPercentDone() || 0, 100)
- };
- o = this.eventRenderer.call(this.eventRendererScope || this, k,
- b, k.store)
- || {};
- var t = this.leftLabelField, j = this.rightLabelField, B;
- if (t) {
- b.leftLabel = t.renderer.call(t.scope || this,
- k.data[t.dataIndex], k)
- }
- if (j) {
- b.rightLabel = j.renderer.call(j.scope || this,
- k.data[j.dataIndex], k)
- }
- Ext.apply(b, o);
- if (C) {
- B = this.milestoneTemplate
- } else {
- b.width = Math.max(1, f);
- var p = "";
- if (u) {
- p = " sch-event-endsoutside "
- }
- if (!q) {
- p = " sch-event-startsoutside "
- }
- b.ctcls = (b.ctcls || "") + p;
- B = this[x ? "eventTemplate" : "parentEventTemplate"]
- }
- var i = " sch-event-resizable-" + k.getResizable();
- if (k.dirty) {
- i += " sch-dirty "
- }
- if (k.isDraggable() === false) {
- i += " sch-event-fixed "
- }
- b.cls = (b.cls || "") + (k.getCls() || "") + i;
- A += B.apply(b)
- }
- }
- if (this.enableBaseline) {
- var r = k.getBaselineStartDate(), a = k.getBaselineEndDate();
- if (!o) {
- o = this.eventRenderer.call(this, k, b, k.store) || {}
- }
- if (r && a) {
- u = a > g;
- q = s.betweenLesser(r, h, g);
- var c = k.isBaselineMilestone(), w = c
- ? this.baselineMilestoneTemplate
- : (k.isLeaf()
- ? this.baselineTaskTemplate
- : this.baselineParentTaskTemplate), m = Math
- .floor(this.getXYFromDate(q ? r : h)[0]), y = c
- ? 0
- : Math.floor(this.getXYFromDate(u ? g : a)[0]) - m;
- A += w.apply({
- basecls : o.basecls || "",
- id : k.internalId + "-base",
- percentDone : k.getBaselinePercentDone(),
- leftOffset : m,
- width : Math.max(1, y)
- })
- }
- }
- return A
- },
- setupTemplates : function() {
- var a = {
- leftLabel : !!this.leftLabelField,
- rightLabel : !!this.rightLabelField,
- prefix : this.eventPrefix,
- enableDependencyDragDrop : this.enableDependencyDragDrop !== false,
- resizeHandles : this.resizeHandles,
- enableProgressBarResize : this.enableProgressBarResize
- };
- if (!this.eventTemplate) {
- a.baseCls = "sch-gantt-task {ctcls}";
- this.eventTemplate = Ext.create("Gnt.template.Task", a)
- }
- if (!this.parentEventTemplate) {
- a.baseCls = "sch-gantt-parent-task {ctcls}";
- this.parentEventTemplate = Ext.create("Gnt.template.ParentTask", a)
- }
- if (!this.milestoneTemplate) {
- a.baseCls = "sch-gantt-milestone {ctcls}";
- this.milestoneTemplate = Ext.create("Gnt.template.Milestone", a)
- }
- if (this.enableBaseline) {
- a = {
- prefix : this.eventPrefix
- };
- if (!this.baselineTaskTemplate) {
- a.baseCls = "sch-gantt-task-baseline sch-gantt-baseline-item {basecls}";
- this.baselineTaskTemplate = Ext.create("Gnt.template.Task", a)
- }
- if (!this.baselineParentTaskTemplate) {
- a.baseCls = "sch-gantt-parenttask-baseline sch-gantt-baseline-item {basecls}";
- this.baselineParentTaskTemplate = Ext.create(
- "Gnt.template.ParentTask", a)
- }
- if (!this.baselineMilestoneTemplate) {
- a.baseCls = "sch-gantt-milestone-baseline sch-gantt-baseline-item {basecls}";
- this.baselineMilestoneTemplate = Ext.create(
- "Gnt.template.Milestone", a)
- }
- }
- },
- getDependencyView : function() {
- return this.dependencyView
- },
- getTaskStore : function() {
- return this.taskStore
- },
- initDependencies : function() {
- if (this.dependencyStore) {
- var b = this, a = Ext.create("Gnt.view.Dependency", Ext.apply({
- containerEl : b.el,
- ganttView : b,
- enableDependencyDragDrop : b.enableDependencyDragDrop,
- store : b.dependencyStore
- }, this.dependencyViewConfig));
- a.on({
- beforednd : b.onBeforeDependencyDrag,
- dndstart : b.onDependencyDragStart,
- drop : b.onDependencyDrop,
- afterdnd : b.onAfterDependencyDragDrop,
- beforecascade : b.onBeforeCascade,
- cascade : b.onCascade,
- scope : b
- });
- b.dependencyView = a;
- b.relayEvents(a, ["dependencydblclick"])
- }
- },
- setupGanttEvents : function() {
- var a = this.getSelectionModel();
- if (this.toggleParentTasksOnClick) {
- this.on({
- taskclick : function(c, b) {
- if (!b.isLeaf()) {
- this.toggle(b)
- }
- },
- scope : this
- })
- }
- },
- configureLabels : function() {
- var c = {
- renderer : function(d) {
- return d
- },
- dataIndex : undefined
- };
- var b = this.leftLabelField;
- if (b) {
- if (Ext.isString(b)) {
- b = this.leftLabelField = {
- dataIndex : b
- }
- }
- Ext.applyIf(b, c);
- if (b.editor) {
- b.editor = Ext.create("Gnt.feature.LabelEditor", this, {
- alignment : "r-r",
- delegate : ".sch-gantt-label-left",
- labelPosition : "left",
- field : b.editor,
- dataIndex : b.dataIndex
- })
- }
- }
- var a = this.rightLabelField;
- if (a) {
- if (Ext.isString(a)) {
- a = this.rightLabelField = {
- dataIndex : a
- }
- }
- Ext.applyIf(a, c);
- if (a.editor) {
- a.editor = Ext.create("Gnt.feature.LabelEditor", this, {
- alignment : "l-l",
- delegate : ".sch-gantt-label-right",
- labelPosition : "right",
- field : a.editor,
- dataIndex : a.dataIndex
- })
- }
- }
- this.on("labeledit_beforestartedit", this.onBeforeLabelEdit, this)
- },
- onBeforeTaskDrag : function(b, a) {
- return !this.readOnly && a.isDraggable() !== false
- && (this.allowParentTaskMove || a.isLeaf())
- },
- onDragDropStart : function() {
- if (this.tip) {
- this.tip.disable()
- }
- },
- onDragDropEnd : function() {
- if (this.tip) {
- this.tip.enable()
- }
- },
- onTaskProgressBarResizeStart : function() {
- if (this.tip) {
- this.tip.hide();
- this.tip.disable()
- }
- },
- onTaskProgressBarResizeEnd : function() {
- if (this.tip) {
- this.tip.enable()
- }
- },
- onTaskResizeStart : function() {
- if (this.tip) {
- this.tip.hide();
- this.tip.disable()
- }
- },
- onTaskResizeEnd : function() {
- if (this.tip) {
- this.tip.enable()
- }
- },
- onBeforeDragCreate : function() {
- return !this.readOnly
- },
- onBeforeTaskResize : function(a, b) {
- return !this.readOnly && b.getSchedulingMode() !== "EffortDriven"
- },
- onBeforeTaskProgressBarResize : function() {
- return !this.readOnly
- },
- onBeforeLabelEdit : function() {
- return !this.readOnly
- },
- onBeforeEdit : function() {
- return !this.readOnly
- },
- beforeRender : function() {
- this.addCls("sch-ganttview");
- this.callParent(arguments)
- },
- afterRender : function() {
- this.initDependencies();
- this.callParent(arguments);
- this.el.on("mousemove", this.configureFeatures, this, {
- single : true
- })
- },
- resolveTaskRecord : function(a) {
- var b = this.findItemByChild(a);
- if (b) {
- return this.getRecord(this.findItemByChild(a))
- }
- return null
- },
- resolveEventRecord : function(a) {
- return this.resolveTaskRecord(a)
- },
- highlightTask : function(b, a) {
- if (!(b instanceof Ext.data.Model)) {
- b = this.taskStore.getById(b)
- }
- if (b) {
- var d = this.getNode(b);
- if (d) {
- Ext.fly(d).addCls("sch-gantt-task-highlighted")
- }
- var c = b.getId() || b.internalId;
- if (a !== false) {
- this.dependencyStore.each(function(e) {
- if (e.getSourceId() == c) {
- this.highlightDependency(e.id);
- this.highlightTask(e.getTargetId(), a)
- }
- }, this)
- }
- }
- },
- unhighlightTask : function(a, c) {
- if (!(a instanceof Ext.data.Model)) {
- a = this.taskStore.getById(a)
- }
- if (a) {
- Ext.fly(this.getNode(a)).removeCls("sch-gantt-task-highlighted");
- var b = a.getId() || a.internalId;
- if (c !== false) {
- this.dependencyStore.each(function(d) {
- if (d.getSourceId() == b) {
- this.unhighlightDependency(d.id);
- this.unhighlightTask(d.getTargetId(), c)
- }
- }, this)
- }
- }
- },
- clearSelectedTasksAndDependencies : function() {
- this.getSelectionModel().deselectAll();
- this.getDependencyView().clearSelectedDependencies();
- this.el.select("tr.sch-gantt-task-highlighted")
- .removeCls("sch-gantt-task-highlighted")
- },
- getCriticalPaths : function() {
- return this.taskStore.getCriticalPaths()
- },
- highlightCriticalPaths : function() {
- this.clearSelectedTasksAndDependencies();
- var g = this.getCriticalPaths(), c = this.getDependencyView(), f = this.dependencyStore, e, d, b, a;
- Ext.each(g, function(h) {
- for (d = 0, b = h.length; d < b; d++) {
- e = h[d];
- this.highlightTask(e, false);
- if (d < (b - 1)) {
- a = f.getAt(f.findBy(function(i) {
- return i.getTargetId() === (e.getId() || e.internalId)
- && i.getSourceId() === (h[d + 1]
- .getId() || h[d + 1].internalId)
- }));
- c.highlightDependency(a)
- }
- }
- }, this);
- this.addCls("sch-gantt-critical-chain");
- this.getSelectionModel().setLocked(true)
- },
- unhighlightCriticalPaths : function() {
- this.el.removeCls("sch-gantt-critical-chain");
- this.getSelectionModel().setLocked(false);
- this.clearSelectedTasksAndDependencies()
- },
- getXOffset : function(a) {
- var b = 0;
- if (a.isMilestone()) {
- b = this.milestoneOffset
- } else {
- if (!a.isLeaf()) {
- b = this.parentTaskOffset
- }
- }
- return b
- },
- onDestroy : function() {
- if (this.dependencyView) {
- this.dependencyView.destroy()
- }
- this.callParent(arguments)
- },
- highlightDependency : function(a) {
- this.dependencyView.highlightDependency(a)
- },
- unhighlightDependency : function(a) {
- this.dependencyView.unhighlightDependency(a)
- },
- onBeforeDependencyDrag : function(b, a) {
- return this.fireEvent("beforedependencydrag", this, a)
- },
- onDependencyDragStart : function(a) {
- this.fireEvent("dependencydragstart", this);
- if (this.tip) {
- this.tip.disable()
- }
- },
- onDependencyDrop : function(b, c, a, d) {
- this.fireEvent("dependencydrop", this, this.taskStore.getNodeById(c),
- this.taskStore.getById(a), d)
- },
- onAfterDependencyDragDrop : function() {
- this.fireEvent("afterdependencydragdrop", this);
- if (this.tip) {
- this.tip.enable()
- }
- },
- onBeforeCascade : function(a, b) {
- this.taskStore.un("update", this.onUpdate, this)
- },
- onCascade : function(a, b) {
- this.taskStore.on("update", this.onUpdate, this)
- },
- onUpdate : function(c, a, b, d) {
- if (d && d.length === 1 && d[0] === "expanded") {
- return
- }
- this.callParent(arguments)
- },
- getLeftEditor : function() {
- return this.leftLabelField.editor
- },
- getRightEditor : function() {
- return this.rightLabelField.editor
- },
- editLeftLabel : function(a) {
- var b = this.leftLabelField && this.getLeftEditor();
- if (b) {
- b.edit(a)
- }
- },
- editRightLabel : function(a) {
- var b = this.rightLabelField && this.getRightEditor();
- if (b) {
- b.edit(a)
- }
- },
- getOuterElementFromEventRecord : function(a) {
- var b = this.callParent([a]);
- return b && b.up(this.eventWrapSelector) || null
- },
- getDependenciesForTask : function(a) {
- console
- .warn("`ganttPanel.getDependenciesForTask()` is deprecated, use `task.getAllDependencies()` instead");
- return a.getAllDependencies()
- },
- setNewTemplate : function() {
- var b = this, a = b.headerCt.getColumnsForTpl(true);
- b.tpl = b.getTableChunker().getTableTpl({
- columns : [a[0]],
- features : b.features
- })
- },
- onAdd : function() {
- Ext.suspendLayouts();
- this.callParent(arguments);
- Ext.resumeLayouts()
- },
- onRemove : function() {
- Ext.suspendLayouts();
- this.callParent(arguments);
- Ext.resumeLayouts()
- }
- });
- Ext.define("Gnt.panel.Gantt", {
- extend : "Sch.panel.TimelineTreePanel",
- alias : ["widget.ganttpanel"],
- alternateClassName : ["Sch.gantt.GanttPanel"],
- requires : ["Gnt.view.Gantt", "Gnt.model.Dependency",
- "Gnt.data.ResourceStore", "Gnt.data.AssignmentStore",
- "Gnt.feature.WorkingTime", "Gnt.data.Calendar",
- "Gnt.data.TaskStore", "Gnt.data.DependencyStore"],
- uses : ["Sch.plugin.CurrentTimeLine"],
- lockedXType : "treepanel",
- normalXType : "ganttpanel",
- viewType : "ganttview",
- syncRowHeight : false,
- layout : "border",
- lightWeight : true,
- leftLabelField : null,
- rightLabelField : null,
- highlightWeekends : true,
- weekendsAreWorkdays : false,
- skipWeekendsDuringDragDrop : true,
- enableTaskDragDrop : true,
- enableDependencyDragDrop : true,
- enableProgressBarResize : false,
- toggleParentTasksOnClick : true,
- addRowOnTab : true,
- recalculateParents : true,
- cascadeChanges : false,
- showTodayLine : false,
- enableBaseline : false,
- baselineVisible : false,
- enableAnimations : false,
- workingTimePlugin : null,
- todayLinePlugin : null,
- allowParentTaskMove : false,
- enableDragCreation : true,
- eventRenderer : Ext.emptyFn,
- eventRendererScope : null,
- eventTemplate : null,
- parentEventTemplate : null,
- milestoneTemplate : null,
- autoHeight : null,
- calendar : null,
- taskStore : null,
- dependencyStore : null,
- resourceStore : null,
- assignmentStore : null,
- columnLines : true,
- dndValidatorFn : Ext.emptyFn,
- createValidatorFn : Ext.emptyFn,
- resizeHandles : "both",
- resizeValidatorFn : Ext.emptyFn,
- resizeConfig : null,
- progressBarResizeConfig : null,
- dragDropConfig : null,
- createConfig : null,
- refreshLockedTreeOnDependencyUpdate : false,
- initStores : function() {
- var a = Ext.StoreMgr.lookup(this.taskStore || this.store);
- if (!a) {
- Ext.Error.raise("You must specify a taskStore config")
- }
- if (!(a instanceof Gnt.data.TaskStore)) {
- Ext.Error
- .raise("A `taskStore` should be an instance of `Gnt.data.TaskStore` (or of a subclass)")
- }
- Ext.apply(this, {
- store : a,
- taskStore : a
- });
- var d = this.calendar = a.calendar;
- if (this.needToTranslateOption("weekendsAreWorkdays")) {
- d.setWeekendsAreWorkDays(this.weekendsAreWorkdays)
- }
- if (a.dependencyStore) {
- this.dependencyStore = a.dependencyStore
- } else {
- if (this.dependencyStore) {
- this.dependencyStore = Ext.StoreMgr
- .lookup(this.dependencyStore);
- a.setDependencyStore(this.dependencyStore)
- } else {
- this.dependencyStore = Ext.create("Gnt.data.DependencyStore");
- a.setDependencyStore(this.dependencyStore)
- }
- }
- if (!(this.dependencyStore instanceof Gnt.data.DependencyStore)) {
- Ext.Error
- .raise("The Gantt dependency store should be a Gnt.data.DependencyStore, or a subclass thereof.")
- }
- var b;
- if (a.getResourceStore()) {
- b = a.getResourceStore()
- } else {
- if (this.resourceStore) {
- b = Ext.StoreMgr.lookup(this.resourceStore)
- } else {
- b = Ext.create("Gnt.data.ResourceStore")
- }
- }
- if (!(b instanceof Gnt.data.ResourceStore)) {
- Ext.Error
- .raise("A `ResourceStore` should be an instance of `Gnt.data.ResourceStore` (or of a subclass)")
- }
- var c;
- if (a.getAssignmentStore()) {
- c = a.getAssignmentStore()
- } else {
- if (this.assignmentStore) {
- c = Ext.StoreMgr.lookup(this.assignmentStore)
- } else {
- c = Ext.create("Gnt.data.AssignmentStore")
- }
- }
- if (!(c instanceof Gnt.data.AssignmentStore)) {
- Ext.Error
- .raise("An `assignmentStore` should be an instance of `Gnt.data.AssignmentStore` (or of a subclass)")
- }
- if (this.lockable) {
- this.bindAssignmentStore(c, true);
- this.bindResourceStore(b, true)
- }
- },
- initComponent : function() {
- if (Ext.isBoolean(this.showBaseline)) {
- this.enableBaseline = this.baselineVisible = this.showBaseline;
- this.showBaseline = Gnt.panel.Gantt.prototype.showBaseline
- }
- this.autoHeight = false;
- this.initStores();
- if (this.needToTranslateOption("cascadeChanges")) {
- this.setCascadeChanges(this.cascadeChanges)
- }
- if (this.needToTranslateOption("recalculateParents")) {
- this.setRecalculateParents(this.recalculateParents)
- }
- if (this.needToTranslateOption("skipWeekendsDuringDragDrop")) {
- this.setSkipWeekendsDuringDragDrop(this.skipWeekendsDuringDragDrop)
- }
- if (this.lockable) {
- this.lockedGridConfig = this.lockedGridConfig || {};
- Ext.apply(this.lockedGridConfig, {
- columnLines : true,
- rowLines : true
- });
- this.configureFunctionality();
- this.mon(this.taskStore, "beforecascade", function(e) {
- var d = this.normalGrid.getView().store;
- d.suspendEvents()
- }, this);
- this.mon(this.taskStore, "cascade", function(h, d) {
- var g = this.normalGrid.getView().store;
- g.resumeEvents();
- if (d.nbrAffected > 0) {
- var e = this.normalGrid.getView();
- var f = this.lockedGrid.getView();
- e.refreshKeepingScroll(true);
- setTimeout(function() {
- f.saveScrollState();
- f.refresh();
- f.restoreScrollState()
- }, 0)
- }
- }, this);
- this.mon(this.taskStore, "refresh", function() {
- this.getSchedulingView().refreshKeepingScroll(true);
- if (Ext.versions.extjs.isLessThan("4.1.2")) {
- var e = this.getSchedulingView().selModel.selected, f = this, d;
- e.each(function(g) {
- d = f.getSchedulingView().store.indexOfId(g
- .getId());
- f.getSchedulingView().onRowSelect(d);
- f.view.lockedView.onRowSelect(d)
- })
- }
- }, this)
- }
- this.callParent(arguments);
- var a = this.getSchedulingView();
- this.relayEvents(a, ["taskclick", "taskdblclick", "taskcontextmenu",
- "beforetaskresize", "taskresizestart",
- "partialtaskresize", "aftertaskresize",
- "beforeprogressbarresize", "progressbarresizestart",
- "afterprogressbarresize", "beforetaskdrag",
- "taskdragstart", "taskdrop", "aftertaskdrop",
- "labeledit_beforestartedit",
- "labeledit_beforecomplete", "labeledit_complete",
- "beforedependencydrag", "dependencydragstart",
- "dependencydrop", "afterdependencydragdrop",
- "dependencydblclick", "beforedragcreate",
- "dragcreatestart", "dragcreateend", "afterdragcreate"]);
- if (this.lockable) {
- this.bodyCls = (this.bodyCls || "")
- + " sch-ganttpanel-container-body";
- a.store.calendar = this.calendar;
- this.fixSelectionModel();
- if (this.addRowOnTab) {
- var b = this.lockedGrid, c = this.getSelectionModel();
- c.onEditorTab = Ext.Function.createInterceptor(c.onEditorTab,
- function(h, i) {
- var g = b.view, f = h.getActiveRecord(), j = h
- .getActiveColumn(), d = g.getPosition(f, j);
- if (!i.shiftKey
- && d.column === b.headerCt.getColumnCount()
- - 1
- && d.row === b.view.store.getCount() - 1) {
- f.addTaskBelow({
- leaf : true
- })
- }
- })
- }
- }
- },
- needToTranslateOption : function(a) {
- return this.hasOwnProperty(a) || this.self.prototype.hasOwnProperty(a)
- && this.self != Gnt.panel.Gantt
- },
- fixSelectionModel : function() {
- var a = this.getSelectionModel();
- var d = this.lockedGrid.getView();
- var c = this.normalGrid.getView();
- d.__lockedType = "locked";
- c.__lockedType = "normal";
- var e = d.onAdd;
- d.onAdd = function() {
- a.__preventUpdateOf = "normal";
- e.apply(this, arguments);
- delete a.__preventUpdateOf
- };
- var b = c.onAdd;
- c.onAdd = function() {
- a.__preventUpdateOf = "locked";
- b.apply(this, arguments);
- delete a.__preventUpdateOf
- };
- var f = d.store;
- d.bindStore(null);
- c.bindStore(null);
- d.bindStore(f);
- c.bindStore(f);
- Ext.apply(a, {
- onSelectChange : function(m, j, q, g) {
- var o = this, r = o.views, k = r.length, p = o.store, h = p
- .indexOf(m), n = j ? "select" : "deselect", l = 0;
- if ((q || o.fireEvent("before" + n, o, m, h)) !== false
- && g() !== false) {
- for (; l < k; l++) {
- if (!this.__preventUpdateOf
- || r[l].__lockedType != this.__preventUpdateOf) {
- if (j) {
- r[l].onRowSelect(h, q)
- } else {
- r[l].onRowDeselect(h, q)
- }
- }
- }
- if (!q) {
- o.fireEvent(n, o, m, h)
- }
- }
- }
- })
- },
- getDependencyView : function() {
- return this.getSchedulingView().getDependencyView()
- },
- disableWeekendHighlighting : function(a) {
- this.workingTimePlugin.setDisabled(a)
- },
- resolveTaskRecord : function(a) {
- return this.getSchedulingView().resolveTaskRecord(a)
- },
- fitTimeColumns : function() {
- this.getSchedulingView().fitColumns()
- },
- getResourceStore : function() {
- return this.getTaskStore().getResourceStore()
- },
- getAssignmentStore : function() {
- return this.getTaskStore().getAssignmentStore()
- },
- getTaskStore : function() {
- return this.taskStore
- },
- getDependencyStore : function() {
- return this.dependencyStore
- },
- onDragDropStart : function() {
- if (this.tip) {
- this.tip.hide();
- this.tip.disable()
- }
- },
- onDragDropEnd : function() {
- if (this.tip) {
- this.tip.enable()
- }
- },
- configureFunctionality : function() {
- var a = this.plugins = [].concat(this.plugins || []);
- if (this.highlightWeekends) {
- this.workingTimePlugin = Ext.create("Gnt.feature.WorkingTime", {
- calendar : this.calendar
- });
- a.push(this.workingTimePlugin)
- }
- if (this.showTodayLine) {
- this.todayLinePlugin = new Sch.plugin.CurrentTimeLine();
- a.push(this.todayLinePlugin)
- }
- },
- getWorkingTimePlugin : function() {
- return this.workingTimePlugin
- },
- beforeRender : function() {
- if (this.lockable) {
- var a = " sch-ganttpanel sch-horizontal ";
- if (this.highlightWeekends) {
- a += " sch-ganttpanel-highlightweekends "
- }
- this.addCls(a);
- if (this.baselineVisible) {
- this.showBaseline()
- }
- }
- this.callParent(arguments)
- },
- updateDependencyTasks : function(b) {
- var a = b.getSourceTask(this.taskStore);
- var c = b.getTargetTask(this.taskStore);
- var d = this.lockedGrid.getView();
- if (a) {
- d.onUpdate(d.store, a)
- }
- if (c) {
- d.onUpdate(d.store, c)
- }
- },
- registerLockedDependencyListeners : function() {
- var c = this;
- var a = this.getDependencyStore();
- var b = {
- load : function() {
- c.lockedGrid.getView().refresh()
- },
- add : function(e, d) {
- for (var f = 0; f < d.length; f++) {
- c.updateDependencyTasks(d[f])
- }
- },
- update : function(e, d) {
- c.updateDependencyTasks(d)
- },
- remove : function(e, d) {
- c.updateDependencyTasks(d)
- }
- };
- a.un(b);
- a.on(b)
- },
- afterRender : function() {
- this.callParent(arguments);
- if (this.lockable) {
- this.applyPatches()
- }
- },
- showBaseline : function() {
- this.addCls("sch-ganttpanel-showbaseline")
- },
- hideBaseline : function() {
- this.removeCls("sch-ganttpanel-showbaseline")
- },
- toggleBaseline : function() {
- this.toggleCls("sch-ganttpanel-showbaseline")
- },
- zoomToFit : function() {
- var a = this.taskStore.getTotalTimeSpan();
- if (a.start && a.end && a.start < a.end) {
- this.setTimeSpan(a.start, a.end);
- this.fitTimeColumns()
- }
- },
- getCascadeChanges : function() {
- return this.taskStore.cascadeChanges
- },
- setCascadeChanges : function(a) {
- this.taskStore.cascadeChanges = a
- },
- getRecalculateParents : function() {
- return this.taskStore.recalculateParents
- },
- setRecalculateParents : function(a) {
- this.taskStore.recalculateParents = a
- },
- setSkipWeekendsDuringDragDrop : function(a) {
- this.taskStore.skipWeekendsDuringDragDrop = this.skipWeekendsDuringDragDrop = a
- },
- getSkipWeekendsDuringDragDrop : function() {
- return this.taskStore.skipWeekendsDuringDragDrop
- },
- applyPatches : function() {
- if (Ext.tree.plugin && Ext.tree.plugin.TreeViewDragDrop) {
- var a;
- Ext.each(this.lockedGrid.getView().plugins, function(b) {
- if (b instanceof Ext.tree.plugin.TreeViewDragDrop) {
- a = b;
- return false
- }
- });
- if (!a || !a.dropZone) {
- return
- }
- a.dropZone.handleNodeDrop = function(e, l, f) {
- var n = this, o = n.view, g = l.parentNode, p = o.getStore(), r = [], b, d, k, c, j, m, q, h;
- if (e.copy) {
- b = e.records;
- e.records = [];
- for (d = 0, k = b.length; d < k; d++) {
- e.records.push(Ext.apply({}, b[d].data))
- }
- }
- n.cancelExpand();
- if (f == "before") {
- c = g.insertBefore;
- j = [null, l];
- l = g
- } else {
- if (f == "after") {
- if (l.nextSibling) {
- c = g.insertBefore;
- j = [null, l.nextSibling]
- } else {
- c = g.appendChild;
- j = [null]
- }
- l = g
- } else {
- if (!l.isExpanded()) {
- m = true
- }
- c = l.appendChild;
- j = [null]
- }
- }
- q = function() {
- var i;
- for (d = 0, k = e.records.length; d < k; d++) {
- j[0] = e.records[d];
- j[0].isMove = true;
- i = c.apply(l, j);
- delete j[0].isMove;
- if (Ext.enableFx && n.dropHighlight) {
- r.push(o.getNode(i))
- }
- }
- if (Ext.enableFx && n.dropHighlight) {
- Ext.Array.forEach(r, function(s) {
- if (s) {
- Ext
- .fly(s.firstChild
- ? s.firstChild
- : s)
- .highlight(n.dropHighlightColor)
- }
- })
- }
- };
- if (m) {
- l.expand(false, q)
- } else {
- q()
- }
- }
- }
- },
- bindResourceStore : function(c, a) {
- var b = this;
- if (!a && b.resourceStore) {
- if (c !== b.resourceStore && b.resourceStore.autoDestroy) {
- b.resourceStore.destroy()
- } else {
- b.mun(b.resourceStore, {
- scope : b,
- datachanged : b.onResourceStoreDataChanged
- })
- }
- if (!c) {
- b.resourceStore = null
- }
- }
- if (c) {
- c = Ext.data.StoreManager.lookup(c);
- b.mon(c, {
- scope : b,
- datachanged : b.onResourceStoreDataChanged
- });
- this.taskStore.setResourceStore(c)
- }
- b.resourceStore = c;
- if (c && !a) {
- b.getView().refreshKeepingScroll()
- }
- },
- bindAssignmentStore : function(c, a) {
- var b = this;
- if (!a && b.assignmentStore) {
- if (c !== b.assignmentStore && b.assignmentStore.autoDestroy) {
- b.assignmentStore.destroy()
- } else {
- b.mun(b.assignmentStore, {
- scope : b,
- datachanged : b.onAssignmentStoreDataChanged
- })
- }
- if (!c) {
- b.assignmentStore = null
- }
- }
- if (c) {
- c = Ext.data.StoreManager.lookup(c);
- b.mon(c, {
- scope : b,
- datachanged : b.onAssignmentStoreDataChanged
- });
- this.taskStore.setAssignmentStore(c)
- }
- b.assignmentStore = c;
- if (c && !a) {
- b.getView().refreshKeepingScroll()
- }
- },
- onResourceStoreDataChanged : function() {
- this.getView().refreshKeepingScroll()
- },
- onAssignmentStoreDataChanged : function() {
- this.getView().refreshKeepingScroll()
- },
- expandAll : function() {
- Ext.suspendLayouts();
- this.callParent(arguments);
- Ext.resumeLayouts()
- },
- collapseAll : function() {
- Ext.suspendLayouts();
- this.callParent(arguments);
- Ext.resumeLayouts()
- }
- });
- Ext.define("Gnt.column.EndDate", {
- extend : "Ext.grid.column.Date",
- alias : "widget.enddatecolumn",
- requires : ["Ext.grid.CellEditor"],
- text : "Finish",
- width : 100,
- align : "left",
- task : null,
- editorFormat : null,
- adjustMilestones : true,
- constructor : function(a) {
- a = a || {};
- var b = a.field || a.editor;
- delete a.field;
- delete a.editor;
- this.field = Ext.create("Ext.grid.CellEditor", {
- ignoreNoChange : true,
- field : b || {
- xtype : "datefield",
- format : a.editorFormat || a.format || this.format
- || Ext.Date.defaultFormat
- },
- listeners : {
- beforecomplete : this.onBeforeEditComplete,
- scope : this
- }
- });
- this.callParent([a]);
- this.scope = this;
- this.renderer = a.renderer || this.rendererFunc;
- this.editorFormat = this.editorFormat || this.format
- },
- beforeRender : function() {
- if (!this.dataIndex) {
- var a = this.up("treepanel");
- this.dataIndex = a.store.model.prototype.endDateField
- }
- this.callParent(arguments)
- },
- rendererFunc : function(c, d, b) {
- if (!c) {
- return
- }
- if (!b.isEditable(this.dataIndex)) {
- d.tdCls = (d.tdCls || "") + " sch-column-readonly"
- }
- var a = c && b.getStartDate() - c === 0;
- if ((!a || this.adjustMilestones)
- && c - Ext.Date.clearTime(c, true) === 0
- && !Ext.Date.formatContainsHourInfo(this.format)) {
- c = Sch.util.Date.add(c, Sch.util.Date.MILLI, -1)
- }
- return Ext.util.Format.date(c, this.format)
- },
- afterRender : function() {
- this.callParent(arguments);
- var a = this.ownerCt.up("treepanel");
- a.on({
- edit : this.onTreeEdit,
- beforeedit : this.onBeforeTreeEdit,
- scope : this
- })
- },
- onBeforeTreeEdit : function(c) {
- if (c.column === this) {
- c.doNotUpdateRecord = true;
- var b = this.task = c.record;
- if (!b.isEditable(this.dataIndex)) {
- return false
- }
- var d = c.value;
- var a = d && b.getStartDate() - d === 0;
- if (d) {
- if ((!a || this.adjustMilestones)
- && d - Ext.Date.clearTime(d, true) === 0
- && !Ext.Date.formatContainsHourInfo(this.editorFormat)) {
- d = Sch.util.Date.add(d, Sch.util.Date.MILLI, -1)
- }
- c.value = Ext.Date.parse(Ext.Date.format(d, this.editorFormat),
- this.editorFormat)
- }
- }
- },
- onBeforeEditComplete : function(d, e, b) {
- var f = Ext.Date.formatContainsHourInfo(this.editorFormat);
- var a = this.task.getStartDate();
- var c = b && a - b === 0;
- if ((!c || this.adjustMilestones) && e && b
- && b - Ext.Date.clearTime(b, true) === 0 && !f) {
- e = Sch.util.Date.add(e, Sch.util.Date.DAY, 1);
- return e >= this.task.getStartDate()
- }
- },
- onTreeEdit : function(c, b) {
- if (b.column === this) {
- if (b.value) {
- var a = b.record;
- var d = b.value;
- if (!Ext.Date.formatContainsHourInfo(this.editorFormat)) {
- d = a.getCalendar().getCalendarDay(d)
- .getAvailabilityEndFor(d)
- || d
- }
- b.record.setEndDate(d, false)
- } else {
- b.record.setEndDate(null)
- }
- }
- }
- });
- Ext.define("Gnt.column.PercentDone", {
- extend : "Ext.grid.column.Number",
- alias : "widget.percentdonecolumn",
- text : "% Done",
- width : 50,
- format : "0",
- align : "center",
- field : {
- xtype : "numberfield",
- minValue : 0,
- maxValue : 100
- },
- beforeRender : function() {
- if (!this.dataIndex) {
- var a = this.up("treepanel");
- this.dataIndex = a.store.model.prototype.percentDoneField
- }
- this.callParent(arguments)
- }
- });
- Ext.define("Gnt.column.StartDate", {
- extend : "Ext.grid.column.Date",
- alias : "widget.startdatecolumn",
- text : "Start",
- width : 100,
- align : "left",
- editorFormat : null,
- adjustMilestones : true,
- constructor : function(a) {
- a = a || {};
- var b = a.field || a.editor;
- delete a.field;
- delete a.editor;
- this.field = Ext.create("Ext.grid.CellEditor", {
- ignoreNoChange : true,
- field : b || {
- xtype : "datefield",
- format : a.editorFormat || a.format
- || this.format
- || Ext.Date.defaultFormat
- }
- });
- this.hasCustomRenderer = true;
- this.callParent([a]);
- this.renderer = a.renderer || this.rendererFunc;
- this.editorFormat = this.editorFormat || this.format
- },
- beforeRender : function() {
- var a = this.up("treepanel");
- if (!this.dataIndex) {
- this.dataIndex = a.store.model.prototype.startDateField
- }
- this.callParent(arguments);
- a.on({
- edit : this.onTreeEdit,
- beforeedit : this.onBeforeTreeEdit,
- scope : this
- })
- },
- rendererFunc : function(a, d, b) {
- if (!a) {
- return
- }
- if (!b.isEditable(this.dataIndex)) {
- d.tdCls = (d.tdCls || "") + " sch-column-readonly"
- }
- var c = b.getEndDate();
- if (this.adjustMilestones && c - a === 0
- && a - Ext.Date.clearTime(a, true) === 0
- && !Ext.Date.formatContainsHourInfo(this.format)) {
- a = Sch.util.Date.add(a, Sch.util.Date.MILLI, -1)
- }
- return Ext.util.Format.date(a, this.format)
- },
- onBeforeTreeEdit : function(c) {
- if (c.column == this) {
- c.doNotUpdateRecord = true;
- var b = c.record;
- if (!b.isEditable(this.dataIndex)) {
- return false
- }
- var a = c.value;
- if (a) {
- if (this.adjustMilestones
- && b.getEndDate() - b.getStartDate() === 0
- && a - Ext.Date.clearTime(a, true) === 0) {
- a = Sch.util.Date.add(a, Sch.util.Date.MILLI, -1)
- }
- c.originalEditorValue = c.value = Ext.Date.parse(
- Ext.Date.format(a, this.editorFormat),
- this.editorFormat)
- }
- }
- },
- onTreeEdit : function(d, c) {
- var b = c.record;
- var e = c.value;
- var a = c.originalValue;
- if (c.column == this) {
- if (!e) {
- b.setStartDate(null)
- } else {
- if (e - c.originalEditorValue !== 0) {
- var f = b.getEndDate();
- if (this.adjustMilestones && f
- && f - b.getStartDate() === 0
- && a - Ext.Date.clearTime(a, true) === 0
- && e - Ext.Date.clearTime(e, true) === 0) {
- e = b.getCalendar().getCalendarDay(e)
- .getAvailabilityEndFor(e)
- || e
- }
- b
- .setStartDate(
- e,
- true,
- b.getTaskStore().skipWeekendsDuringDragDrop)
- }
- }
- }
- }
- });
- Ext.define("Gnt.column.WBS", {
- extend : "Ext.grid.column.Column",
- alias : "widget.wbscolumn",
- text : "#",
- width : 40,
- align : "left",
- dataIndex : "index",
- renderer : function(f, g, b, h, d, e) {
- var a = e.getRootNode(), c = [];
- while (b !== a) {
- c.push(b.data.index + 1);
- b = b.parentNode
- }
- return c.reverse().join(".")
- }
- });
- Ext.define("Gnt.column.SchedulingMode", {
- extend : "Ext.grid.column.Column",
- alias : "widget.schedulingmodecolumn",
- text : "Mode",
- width : 100,
- align : "left",
- data : [["FixedDuration", "Fixed duration"],
- ["EffortDriven", "Effort driven"],
- ["DynamicAssignment", "Dynamic assignment"],
- ["Manual", "Manual"], ["Normal", "Normal"]],
- modeNames : null,
- pickerAlign : "tl-bl?",
- matchFieldWidth : true,
- constructor : function(a) {
- a = a || {};
- var c = a.field || a.editor;
- a.field = c || {
- xtype : "combo",
- editable : false,
- store : this.data,
- pickerAlign : this.pickerAlign,
- matchFieldWidth : this.matchFieldWidth
- };
- var b = this.modeNames = {};
- Ext.Array.each(this.data, function(d) {
- b[d[0]] = d[1]
- });
- this.scope = this;
- this.callParent([a])
- },
- beforeRender : function() {
- if (!this.dataIndex) {
- var a = this.up("treepanel");
- this.dataIndex = a.store.model.prototype.schedulingModeField
- }
- this.callParent(arguments)
- },
- renderer : function(a) {
- return this.modeNames[a]
- },
- afterRender : function() {
- this.callParent(arguments);
- this.tree = this.ownerCt.up("treepanel");
- this.tree.on("edit", this.onTreeEdit, this)
- },
- onTreeEdit : function(b, a) {
- if (a.column == this) {
- a.record.setSchedulingMode(a.value)
- }
- }
- });
- Ext.define("Gnt.column.ResourceAssignment", {
- extend : "Ext.grid.column.Column",
- alias : "widget.resourceassignmentcolumn",
- text : "Assigned Resources",
- tdCls : "sch-assignment-cell",
- showUnits : true,
- assignmentStore : null,
- initComponent : function() {
- this.formatString = "{0}" + (this.showUnits ? " [{1}%]" : "");
- this.callParent(arguments)
- },
- afterRender : function() {
- this.scope = this;
- this.callParent(arguments);
- this.assignmentStore = this.getOwnerHeaderCt().up("ganttpanel").assignmentStore
- },
- renderer : function(k, o, b, h, n, m, j) {
- var g = [], e = this.assignmentStore, a, f = b.getInternalId();
- if (e.resourceStore.getCount() > 0) {
- for (var d = 0, c = e.getCount(); d < c; d++) {
- a = e.getAt(d);
- if (a.getTaskId() === f) {
- g.push(Ext.String.format(this.formatString, a
- .getResourceName(), a.getUnits()))
- }
- }
- return g.join(", ")
- }
- }
- });
- Ext.define("Gnt.column.ResourceName", {
- extend : "Ext.grid.column.Column",
- alias : "widget.resourcenamecolumn",
- text : "Resource Name",
- dataIndex : "ResourceName",
- flex : 1,
- align : "left"
- });
- Ext.define("Gnt.column.AssignmentUnits", {
- extend : "Ext.grid.column.Number",
- alias : "widget.assignmentunitscolumn",
- text : "Units",
- dataIndex : "Units",
- format : "0 %",
- align : "left"
- });
- Ext.define("Gnt.widget.AssignmentGrid", {
- requires : ["Gnt.model.Resource", "Gnt.model.Assignment",
- "Gnt.column.ResourceName", "Gnt.column.AssignmentUnits",
- "Ext.grid.plugin.CellEditing"],
- extend : "Ext.grid.Panel",
- alias : "widget.assignmentgrid",
- readOnly : false,
- cls : "gnt-assignmentgrid",
- defaultAssignedUnits : 100,
- sorter : {
- sorterFn : function(b, a) {
- var d = b.getUnits(), c = a.getUnits();
- if ((!d && !c) || (d && c)) {
- return b.get("ResourceName") < a.get("ResourceName")
- ? -1
- : 1
- }
- return d ? -1 : 1
- }
- },
- constructor : function(a) {
- this.store = Ext.create("Ext.data.JsonStore", {
- model : Ext.define("Gnt.model.AssignmentEditing", {
- extend : "Gnt.model.Assignment",
- fields : ["ResourceName"]
- })
- });
- this.columns = this.buildColumns();
- if (!this.readOnly) {
- this.plugins = this.buildPlugins()
- }
- Ext.apply(this, {
- selModel : {
- selType : "checkboxmodel",
- mode : "MULTI",
- checkOnly : true,
- selectByPosition : function(b) {
- var c = this.store.getAt(b.row);
- this.select(c, true)
- }
- }
- });
- this.callParent(arguments)
- },
- initComponent : function() {
- this.loadResources();
- this.resourceStore.on({
- datachanged : this.loadResources,
- scope : this
- });
- this.getSelectionModel().on("select", this.onSelect, this, {
- delay : 50
- });
- this.callParent(arguments)
- },
- onSelect : function(b, a) {
- if ((!this.cellEditing || !this.cellEditing.getActiveEditor())
- && !a.getUnits()) {
- a.setUnits(this.defaultAssignedUnits)
- }
- },
- loadResources : function() {
- var d = [], b = this.resourceStore, e;
- for (var c = 0, a = b.getCount(); c < a; c++) {
- e = b.getAt(c).getId();
- d.push({
- ResourceId : e,
- ResourceName : b.getById(e).getName()
- })
- }
- this.store.loadData(d)
- },
- buildPlugins : function() {
- var a = this.cellEditing = Ext.create(
- "Ext.grid.plugin.CellEditing", {
- clicksToEdit : 1
- });
- a.on("edit", this.onEditingDone, this);
- return [a]
- },
- hide : function() {
- this.cellEditing.cancelEdit();
- this.callParent(arguments)
- },
- onEditingDone : function(a, b) {
- if (b.value) {
- this.getSelectionModel().select(b.record, true)
- } else {
- this.getSelectionModel().deselect(b.record);
- b.record.reject()
- }
- },
- buildColumns : function() {
- return [{
- xtype : "resourcenamecolumn",
- resourceStore : this.resourceStore
- }, {
- xtype : "assignmentunitscolumn",
- assignmentStore : this.assignmentStore,
- editor : {
- xtype : "numberfield",
- minValue : 0,
- step : 10
- }
- }]
- },
- loadTaskAssignments : function(d) {
- var b = this.store, f = this.getSelectionModel();
- f.deselectAll(true);
- for (var c = 0, a = b.getCount(); c < a; c++) {
- b.getAt(c).data.Units = "";
- b.getAt(c).data.Id = null
- }
- b.suspendEvents();
- var e = this.assignmentStore.queryBy(function(g) {
- return g.getTaskId() === d
- });
- e.each(function(h) {
- var g = b.findRecord("ResourceId", h
- .getResourceId(), 0, false, true,
- true);
- if (g) {
- g.setUnits(h.getUnits());
- g.set(g.idProperty, h.getId());
- f.select(g, true, true)
- }
- });
- b.resumeEvents();
- b.sort(this.sorter);
- this.getView().refresh()
- }
- });
- Ext.define("Gnt.widget.AssignmentField", {
- extend : "Ext.form.field.Picker",
- alias : "widget.assignmenteditor",
- requires : ["Gnt.widget.AssignmentGrid"],
- matchFieldWidth : false,
- editable : false,
- cancelText : "Cancel",
- closeText : "Save and Close",
- assignmentStore : null,
- resourceStore : null,
- gridConfig : null,
- createPicker : function() {
- var a = new Gnt.widget.AssignmentGrid(Ext.apply({
- ownerCt : this.ownerCt,
- renderTo : document.body,
- frame : true,
- floating : true,
- hidden : true,
- height : 200,
- width : 300,
- resourceStore : this.resourceStore,
- assignmentStore : this.assignmentStore,
- fbar : this.buildButtons()
- }, this.gridConfig || {}));
- return a
- },
- buildButtons : function() {
- return ["->", {
- text : this.closeText,
- handler : function() {
- Ext.Function.defer(this.onGridClose, Ext.isIE
- && !Ext.isIE9 ? 60 : 30, this)
- },
- scope : this
- }, {
- text : this.cancelText,
- handler : this.collapse,
- scope : this
- }]
- },
- onExpand : function() {
- var a = this.resourceStore, b = this.picker;
- b.loadTaskAssignments(this.taskId)
- },
- onGridClose : function() {
- var b = this.picker.getSelectionModel(), a = b.selected;
- this.fireEvent("select", this, a);
- this.collapse()
- },
- collapseIf : function(b) {
- var a = this;
- if (this.picker && !b.getTarget(".x-editor")
- && !b.getTarget(".x-menu-item")) {
- a.callParent(arguments)
- }
- },
- mimicBlur : function(b) {
- var a = this;
- if (!b.getTarget(".x-editor") && !b.getTarget(".x-menu-item")) {
- a.callParent(arguments)
- }
- }
- });
- Ext.define("Gnt.widget.AssignmentCellEditor", {
- extend : "Ext.grid.CellEditor",
- requires : ["Gnt.model.Assignment", "Gnt.widget.AssignmentField"],
- assignmentStore : null,
- resourceStore : null,
- taskId : null,
- fieldConfig : null,
- allowBlur : false,
- constructor : function(a) {
- a = a || {};
- var b = a.fieldConfig || {};
- this.field = Ext.create("Gnt.widget.AssignmentField", Ext
- .apply(b, {
- assignmentStore : a.assignmentStore,
- resourceStore : a.resourceStore
- }));
- this.field.on({
- select : this.onSelect,
- collapse : this.cancelEdit,
- scope : this
- });
- this.callParent(arguments)
- },
- startEdit : function(c, d, b) {
- this.parentEl = null;
- var a = c.child("div").dom.innerHTML;
- this.taskId = this.field.taskId = b.record.getInternalId();
- this.callParent([c, a === " " ? "" : a]);
- this.field.expand()
- },
- onSelect : function(g, c) {
- this.completeEdit();
- var a = this.assignmentStore, f = this.taskId;
- var e = {};
- var d = [];
- c.each(function(i) {
- var h = i.getUnits();
- if (h > 0) {
- var k = i.getId();
- if (k) {
- e[k] = true;
- a.getById(k).setUnits(h)
- } else {
- var j = Ext.create(a.model);
- j.setTaskId(f);
- j.setResourceId(i.getResourceId());
- j.setUnits(h);
- e[j.internalId] = true;
- d.push(j)
- }
- }
- });
- var b = [];
- a.each(function(h) {
- if (h.getTaskId() === f
- && !e[h.getId() || h.internalId]) {
- b.push(h)
- }
- });
- a.remove(b);
- a.add(d)
- }
- });
- Ext.define("Gnt.widget.DependencyField", {
- extend : "Ext.form.field.Text",
- alias : "widget.dependencyfield",
- requires : ["Gnt.util.DependencyParser"],
- constructor : function(a) {
- var b = this;
- Ext.apply(this, a);
- this.dependencyParser = new Gnt.util.DependencyParser({
- parseNumberFn : function() {
- return Gnt.widget.DurationField.prototype.parseValue
- .apply(b, arguments)
- }
- });
- this.callParent(arguments)
- },
- getDependencies : function() {
- return this.dependencyParser.parse(this.getRawValue())
- },
- getErrors : function(b) {
- if (!b) {
- return
- }
- var a = this.dependencyParser.parse(b);
- if (!a) {
- return ["Invalid dependency format"]
- }
- return this.callParent([a.value])
- }
- });
- Ext.define("Gnt.widget.DependencyEditor", {
- extend : "Ext.grid.CellEditor",
- alias : ["widget.dependencyeditor"],
- context : null,
- taskStore : null,
- dependencyStore : null,
- type : "predecessors",
- constructor : function(a) {
- a = a || {};
- Ext.apply(this, a);
- a.field = a.field || Ext.create("Gnt.widget.DependencyField", {});
- this.callParent([a])
- },
- startEdit : function(b, c, a) {
- this.context = a;
- var d = b.hasCls(".x-grid-cell-inner") ? b : b
- .down(".x-grid-cell-inner");
- c = Ext.String.trim(d.dom.innerText || d.dom.innerHTML).replace(
- " ", "");
- return this.callParent([b, c, a])
- },
- completeEdit : function(a) {
- var b = this, e = b.field, d;
- if (!b.editing) {
- return
- }
- d = b.getValue();
- if (!e.isValid()) {
- if (b.revertInvalid !== false) {
- b.cancelEdit(a)
- }
- return
- }
- if (String(d) === String(b.startValue) && b.ignoreNoChange) {
- b.hideEdit(a);
- return
- }
- if (b.fireEvent("beforecomplete", b, d, b.startValue) !== false) {
- d = b.getValue();
- if (b.updateEl && b.boundEl) {
- b.boundEl.update(d)
- }
- var c = this.field.getDependencies();
- if (this.validateDependencies(c)) {
- this.processDependencies(c);
- b.hideEdit(a);
- b.fireEvent("complete", b, d, b.startValue)
- }
- }
- },
- validateDependencies : function(e) {
- var a = this.type === "predecessors";
- for (var d = 0; d < e.length; d++) {
- var c = a ? e[d].taskId : this.context.record.getInternalId();
- var b = !a ? e[d].taskId : this.context.record.getInternalId();
- if (!this.taskStore.getById(e[d].taskId)
- || (!this.dependencyStore.areTasksLinked(c, b) && !this.dependencyStore
- .isValidDependency(c, b))) {
- return false
- }
- }
- return true
- },
- processDependencies : function(h) {
- var m = this.dependencyStore, d = this.context, e = d.record, a = Ext.Array
- .pluck(h, "taskId"), k = this.type === "predecessors", l = k
- ? e.getIncomingDependencies()
- : e.getOutgoingDependencies(), c = [];
- for (var g = 0; g < l.length; g++) {
- if (!Ext.Array.contains(a,
- l[g][k ? "getSourceId" : "getTargetId"]())) {
- c.push(l[g])
- }
- }
- if (c.length > 0) {
- m.remove(c)
- }
- var n = [];
- for (g = 0; g < h.length; g++) {
- var f = h[g];
- var b = f.taskId;
- var j = m.getByTaskIds(b, e.getInternalId());
- if (j) {
- j.beginEdit();
- j.setType(f.type);
- j.setLag(f.lag);
- j.setLagUnit(f.lagUnit);
- j.endEdit()
- } else {
- n.push(new m.model({
- fromTask : k ? b : e.getInternalId(),
- toTask : k ? e.getInternalId() : b,
- type : f.type,
- lag : f.lag,
- lagUnit : f.lagUnit
- }))
- }
- }
- if (n.length > 0) {
- m.add(n)
- }
- if (n.length || c.length) {
- e.afterEdit(["--dependency--"])
- }
- }
- });
- Ext.define("Gnt.widget.DurationField", {
- extend : "Ext.form.field.Number",
- requires : ["Gnt.util.DurationParser"],
- alias : "widget.durationfield",
- alternateClassName : "Gnt.column.duration.Field",
- disableKeyFilter : true,
- minValue : 0,
- durationUnit : "h",
- invalidText : "Invalid duration value",
- useAbbreviation : false,
- durationParser : null,
- durationParserConfig : null,
- constructor : function(a) {
- var b = this;
- Ext.apply(this, a);
- this.durationParser = new Gnt.util.DurationParser(Ext.apply({
- parseNumberFn : function() {
- return b.parseValue.apply(b, arguments)
- },
- allowDecimals : this.decimalPrecision > 0
- }, this.durationParserConfig));
- this.callParent(arguments)
- },
- rawToValue : function(b) {
- var a = this.parseDuration(b);
- if (!a) {
- return null
- }
- this.durationUnit = a.unit;
- return a.value != null ? a.value : null
- },
- valueToRaw : function(a) {
- if (Ext.isNumber(a)) {
- return parseFloat(Ext.Number.toFixed(a,
- this.decimalPrecision))
- + " "
- + Sch.util.Date[this.useAbbreviation
- ? "getShortNameOfUnit"
- : "getReadableNameOfUnit"](
- this.durationUnit, a !== 1)
- }
- return ""
- },
- parseDuration : function(b) {
- if (b == null) {
- return null
- }
- var a = this;
- var c = this.durationParser.parse(b);
- if (!c) {
- return null
- }
- c.unit = c.unit || this.durationUnit;
- return c
- },
- getDurationValue : function() {
- var a = this;
- return this.parseDuration(this.getRawValue())
- },
- getErrors : function(b) {
- var a = this.parseDuration(b);
- if (!a) {
- return [this.invalidText]
- }
- return this.callParent([a.value])
- },
- checkChange : function() {
- if (!this.suspendCheckChange) {
- var d = this, c = d.getDurationValue(), a = d.lastValue;
- var b = c && !a || !c && a || c && a
- && (c.value != a.value || c.unit != a.unit);
- if (b && !d.isDestroyed) {
- d.lastValue = c;
- d.fireEvent("change", d, c, a);
- d.onChange(c, a)
- }
- }
- }
- });
- Ext.define("Gnt.widget.DurationEditor", {
- extend : "Ext.grid.CellEditor",
- alias : ["widget.durationeditor", "widget.durationcolumneditor"],
- alternateClassName : "Gnt.column.duration.Editor",
- context : null,
- decimalPrecision : 2,
- getDurationUnitMethod : "getDurationUnit",
- setDurationMethod : "setDuration",
- useAbbreviation : false,
- constructor : function(a) {
- a = a || {};
- Ext.apply(this, a);
- a.field = a.field || Ext.create("Gnt.widget.DurationField", {
- useAbbreviation : this.useAbbreviation,
- decimalPrecision : this.decimalPrecision
- });
- this.callParent([a])
- },
- startEdit : function(c, b, a) {
- this.context = a;
- this.field.durationUnit = a.record[this.getDurationUnitMethod]();
- return this.callParent(arguments)
- },
- completeEdit : function(a) {
- var d = this, g = d.field, e;
- if (!d.editing) {
- return
- }
- if (g.assertValue) {
- g.assertValue()
- }
- e = d.getValue();
- if (!g.isValid()) {
- if (d.revertInvalid !== false) {
- d.cancelEdit(a)
- }
- return
- }
- if (String(e) === String(d.startValue) && d.ignoreNoChange) {
- d.hideEdit(a);
- return
- }
- if (d.fireEvent("beforecomplete", d, e, d.startValue) !== false) {
- e = d.getValue();
- if (d.updateEl && d.boundEl) {
- d.boundEl.update(e)
- }
- d.hideEdit(a);
- var c = this.context;
- var b = c.record;
- var f = this.field.getDurationValue();
- b[this.setDurationMethod](f.value, f.unit);
- d.fireEvent("complete", d, e, d.startValue)
- }
- }
- });
- Ext.define("Gnt.column.Dependency", {
- extend : "Ext.grid.column.Column",
- requires : ["Gnt.widget.DependencyField", "Gnt.widget.DependencyEditor"],
- separator : ";",
- type : "predecessors",
- dataIndex : "--dependency--",
- constructor : function(a) {
- a = a || {};
- Ext.apply(this, a);
- a.editor = a.editor || Ext.create("Gnt.widget.DependencyEditor", {
- type : this.type
- });
- if (!a.editor.isFormField) {
- a.editor = Ext.ComponentManager
- .create(a.editor, "dependencyeditor")
- }
- this.scope = this;
- this.callParent([a])
- },
- beforeRender : function() {
- var a = this.up("ganttpanel");
- a.registerLockedDependencyListeners();
- this.dependencyStore = a.getDependencyStore();
- if (this.editor) {
- this.editor.taskStore = a.getTaskStore();
- this.editor.dependencyStore = a.getDependencyStore()
- }
- this.callParent(arguments)
- },
- renderer : function(j, n, a) {
- if (!a.isEditable(this.dataIndex)) {
- n.tdCls = (n.tdCls || "") + " sch-column-readonly"
- }
- var h = this.type === "predecessors", m = this.getDependencies(a), k = Gnt.util.DependencyParser.prototype.types, e = Gnt.model.Dependency.Type.EndToStart, l = [];
- for (var d = 0; d < m.length; d++) {
- var g = m[d];
- if (g.isValid(false)) {
- var f = g.getType(), b = g.getLag(), c = g.getLagUnit();
- l.push(Ext.String.format("{0}{1}{2}{3}{4}", h
- ? g.getSourceId()
- : g.getTargetId(), b || f !== e ? k[f] : "", b
- ? "+"
- : "", b || "", b && c !== "d" ? c : ""))
- }
- }
- return l.join(this.separator)
- }
- });
- Ext.define("Gnt.column.Successor", {
- extend : "Gnt.column.Dependency",
- alias : "widget.successorcolumn",
- text : "Successors",
- type : "successors",
- getDependencies : function(a) {
- return a.getOutgoingDependencies()
- }
- });
- Ext.define("Gnt.column.Predecessor", {
- extend : "Gnt.column.Dependency",
- alias : "widget.predecessorcolumn",
- text : "Predecessors",
- type : "predecessors",
- getDependencies : function(a) {
- return a.getIncomingDependencies()
- }
- });
- Ext.define("Gnt.column.Duration", {
- extend : "Ext.grid.column.Column",
- alias : "widget.durationcolumn",
- requires : ["Gnt.widget.DurationField", "Gnt.widget.DurationEditor"],
- text : "Duration",
- width : 80,
- align : "left",
- decimalPrecision : 2,
- getDurationUnitMethod : "getDurationUnit",
- setDurationMethod : "setDuration",
- useAbbreviation : false,
- constructor : function(a) {
- a = a || {};
- Ext.apply(this, a);
- a.editor = a.editor
- || Ext.create("Gnt.widget.DurationEditor", {
- useAbbreviation : this.useAbbreviation,
- decimalPrecision : this.decimalPrecision,
- getDurationUnitMethod : this.getDurationUnitMethod,
- setDurationMethod : this.setDurationMethod
- });
- if (!a.editor.isFormField) {
- a.editor = Ext.ComponentManager.create(a.editor,
- "durationcolumneditor")
- }
- this.scope = this;
- this.callParent([a]);
- this.mon(this.editor, "beforestartedit",
- this.onBeforeStartEdit, this)
- },
- beforeRender : function() {
- if (!this.dataIndex) {
- var a = this.up("treepanel");
- this.dataIndex = a.store.model.prototype.durationField
- }
- this.callParent(arguments)
- },
- onBeforeStartEdit : function(b) {
- var a = b.context.record;
- return a.isEditable(this.dataIndex)
- },
- renderer : function(b, c, a) {
- if (!Ext.isNumber(b)) {
- return ""
- }
- if (!a.isEditable(this.dataIndex)) {
- c.tdCls = (c.tdCls || "") + " sch-column-readonly"
- }
- b = parseFloat(Ext.Number.toFixed(b, this.decimalPrecision));
- return b
- + " "
- + Sch.util.Date[this.useAbbreviation
- ? "getShortNameOfUnit"
- : "getReadableNameOfUnit"](
- a[this.getDurationUnitMethod](), b !== 1)
- }
- });
- Ext.define("Gnt.column.Effort", {
- extend : "Gnt.column.Duration",
- alias : "widget.effortcolumn",
- text : "Effort",
- getDurationUnitMethod : "getEffortUnit",
- setDurationMethod : "setEffort",
- beforeRender : function() {
- if (!this.dataIndex) {
- var a = this.up("treepanel");
- this.dataIndex = a.store.model.prototype.effortField
- }
- this.callParent(arguments)
- }
- });
- Ext.define("Gnt.widget.Calendar", {
- extend : "Ext.picker.Date",
- alias : "widget.ganttcalendar",
- requires : ["Gnt.data.Calendar", "Sch.util.Date"],
- calendar : null,
- startDate : null,
- endDate : null,
- disabledDatesText : "Holiday",
- initComponent : function() {
- if (!this.calendar) {
- Ext.Error
- .raise('Required attribute "calendar" missing during initialization of `Gnt.widget.Calendar`')
- }
- if (!this.startDate) {
- Ext.Error
- .raise('Required attribute "startDate" missing during initialization of `Gnt.widget.Calendar`')
- }
- if (!this.endDate) {
- this.endDate = Sch.util.Date.add(this.startDate,
- Sch.util.Date.MONTH, 1)
- }
- this.setCalendar(this.calendar);
- this.minDate = this.value = this.startDate;
- this.injectDates();
- this.callParent(arguments)
- },
- injectDates : function() {
- var a = this;
- var b = a.disabledDates = [];
- Ext.each(a.calendar.getHolidaysRanges(a.startDate, a.endDate),
- function(c) {
- c.forEachDate(function(d) {
- b.push(Ext.Date.format(d, a.format))
- })
- });
- a.setDisabledDates(b)
- },
- setCalendar : function(b) {
- var a = {
- update : this.injectDates,
- remove : this.injectDates,
- add : this.injectDates,
- load : this.injectDates,
- clear : this.injectDates,
- scope : this
- };
- if (this.calendar) {
- this.calendar.un(a)
- }
- this.calendar = b;
- b.on(a)
- }
- });
- Ext.define("Gnt.widget.calendar.DayGrid", {
- extend : "Ext.grid.Panel",
- title : "Day overrides",
- height : 180,
- nameText : "Name",
- dateText : "Date",
- noNameText : "[Day override]",
- initComponent : function() {
- Ext.applyIf(this, {
- store : Ext.create("Gnt.data.Calendar", {
- proxy : "memory"
- }),
- plugins : [Ext.create(
- "Ext.grid.plugin.CellEditing", {
- clicksToEdit : 2
- })],
- columns : [{
- header : this.nameText,
- dataIndex : "Name",
- flex : 1,
- editor : {
- allowBlank : false
- }
- }, {
- header : this.dateText,
- dataIndex : "Date",
- width : 100,
- xtype : "datecolumn",
- editor : {
- xtype : "datefield"
- }
- }]
- });
- this.callParent(arguments)
- }
- });
- Ext.define("Gnt.widget.calendar.WeekGrid", {
- extend : "Ext.grid.Panel",
- requires : ["Gnt.model.WeekAvailability"],
- title : "Week overrides",
- border : true,
- height : 220,
- nameText : "Name",
- startDateText : "Start date",
- endDateText : "End date",
- initComponent : function() {
- Ext.applyIf(this, {
- store : Ext.create("Ext.data.Store", {
- model : "Gnt.model.WeekAvailability",
- proxy : "memory"
- })
- });
- Ext.applyIf(this, {
- columns : [{
- header : this.nameText,
- dataIndex : this.store.model.prototype.nameField,
- flex : 1,
- editor : {
- allowBlank : false
- }
- }, {
- header : this.startDateText,
- dataIndex : this.store.model.prototype.startDateField,
- width : 100,
- xtype : "datecolumn",
- editor : {
- xtype : "datefield"
- }
- }, {
- header : this.endDateText,
- dataIndex : this.store.model.prototype.endDateField,
- width : 100,
- xtype : "datecolumn",
- editor : {
- xtype : "datefield"
- }
- }],
- plugins : [Ext.create("Ext.grid.plugin.CellEditing", {
- clicksToEdit : 2
- })]
- });
- this.callParent(arguments)
- }
- });
- Ext.define("Gnt.widget.calendar.ResourceCalendarGrid", {
- extend : "Ext.grid.Panel",
- requires : ["Gnt.data.Calendar", "Sch.util.Date"],
- alias : "widget.resourcecalendargrid",
- resourceStore : null,
- calendarStore : null,
- initComponent : function() {
- var a = this;
- this.calendarStore = this.calendarStore
- || Ext.create("Ext.data.Store", {
- fields : ["Id", "Name"]
- });
- Ext.apply(a, {
- store : a.resourceStore,
- columns : [{
- header : "Name",
- dataIndex : "Name",
- flex : 1
- }, {
- header : "Calendar",
- dataIndex : "CalendarId",
- flex : 1,
- renderer : function(f, h, b, e, d, c) {
- if (!f) {
- var g = b.getCalendar();
- f = g ? g.calendarId : ""
- }
- var i = a.calendarStore.getById(f);
- return i ? i.get("Name") : f
- },
- editor : {
- xtype : "combobox",
- store : a.calendarStore,
- queryMode : "local",
- displayField : "Name",
- valueField : "Id",
- editable : false,
- allowBlank : false
- }
- }],
- border : true,
- height : 180,
- plugins : [Ext.create(
- "Ext.grid.plugin.CellEditing", {
- clicksToEdit : 2
- })]
- });
- this.calendarStore.loadData(this.getCalendarData());
- this.callParent(arguments)
- },
- getCalendarData : function() {
- var a = [];
- Ext.Array.each(Gnt.data.Calendar.getAllCalendars(),
- function(b) {
- a.push({
- Id : b.calendarId,
- Name : b.name || b.calendarId
- })
- });
- return a
- }
- });
- Ext.define("Gnt.widget.calendar.DayAvailabilityGrid", {
- extend : "Ext.grid.Panel",
- requires : ["Gnt.data.Calendar", "Sch.util.Date"],
- alias : "widget.dayavailabilitygrid",
- height : 160,
- calendarDay : null,
- startText : "Start",
- endText : "End",
- addText : "Add",
- removeText : "Remove",
- workingTimeText : "Working time",
- nonworkingTimeText : "Non-working time",
- getDayTypeRadioGroup : function() {
- return this.down('radiogroup[name="dayType"]')
- },
- initComponent : function() {
- Ext.applyIf(this, {
- store : Ext.create("Ext.data.Store", {
- fields : ["startTime", "endTime"],
- proxy : {
- type : "memory",
- reader : {
- type : "json"
- }
- }
- }),
- plugins : [Ext.create("Ext.grid.plugin.CellEditing", {
- clicksToEdit : 2
- })],
- dockedItems : [{
- xtype : "radiogroup",
- dock : "top",
- name : "dayType",
- padding : "0 5px",
- margin : 0,
- items : [{
- boxLabel : this.workingTimeText,
- name : "IsWorkingDay",
- inputValue : true
- }, {
- boxLabel : this.nonworkingTimeText,
- name : "IsWorkingDay",
- inputValue : false
- }],
- listeners : {
- change : this.onDayTypeChanged,
- scope : this
- }
- }],
- tbar : this.buildToolbar(),
- columns : [{
- header : this.startText,
- xtype : "datecolumn",
- format : "g:i a",
- dataIndex : "startTime",
- flex : 1,
- editor : {
- xtype : "timefield",
- allowBlank : false,
- initDate : "31/12/1899"
- }
- }, {
- header : this.endText,
- xtype : "datecolumn",
- format : "g:i a",
- dataIndex : "endTime",
- flex : 1,
- editor : {
- allowBlank : false,
- xtype : "timefield",
- initDate : "31/12/1899"
- }
- }],
- listeners : {
- selectionchange : this.onAvailabilityGridSelectionChange,
- scope : this
- }
- });
- this.callParent(arguments)
- },
- buildToolbar : function() {
- this.addButton = new Ext.Button({
- text : this.addText,
- iconCls : "gnt-action-add",
- handler : this.addAvailability,
- scope : this
- });
- this.removeButton = new Ext.Button({
- text : this.removeText,
- iconCls : "gnt-action-remove",
- handler : this.removeAvailability,
- scope : this,
- disabled : true
- });
- return [this.addButton, this.removeButton]
- },
- onAvailabilityGridSelectionChange : function(a) {
- if (this.removeButton) {
- this.removeButton.setDisabled(!a || a.getSelection().length === 0)
- }
- },
- onDayTypeChanged : function(a) {
- var b = a.getValue();
- if (Ext.isArray(b.IsWorkingDay)) {
- return
- }
- this.getView().setDisabled(!b.IsWorkingDay)
- },
- addAvailability : function() {
- var a = this.getStore(), b = a.count();
- if (b >= 5) {
- return
- }
- a.add({
- startTime : new Date(0, 0, 0, 12, 0),
- endTime : new Date(0, 0, 0, 13, 0)
- });
- if (b + 1 >= 5 && this.addButton) {
- this.addButton.setDisabled(true)
- }
- },
- removeAvailability : function() {
- var b = this.getStore(), c = b.count(), d = this.getSelectionModel();
- if (!d || d.getSelection().length === 0) {
- return
- }
- var a = d.getSelection()[0];
- b.remove(a);
- if (c < 5 && this.addButton) {
- this.addButton.setDisabled(false)
- }
- },
- editAvailability : function(a) {
- this.calendarDay = a;
- this.getDayTypeRadioGroup().setValue({
- IsWorkingDay : a.getIsWorkingDay()
- });
- var b = this.calendarDay.getAvailability();
- this.getStore().loadData(b)
- },
- isWorkingDay : function() {
- return this.getDayTypeRadioGroup().getValue().IsWorkingDay
- },
- isValid : function() {
- var c = this.getDayTypeRadioGroup().getValue().IsWorkingDay, b = [];
- if (c) {
- try {
- b = this.getIntervals();
- this.calendarDay.verifyAvailability(b)
- } catch (a) {
- Ext.MessageBox.alert("Error", a);
- return false
- }
- }
- return true
- },
- getIntervals : function() {
- var a = [];
- this.getStore().each(function(b) {
- a.push({
- startTime : b.get("startTime"),
- endTime : b.get("endTime")
- })
- });
- return a
- }
- });
- Ext.define("Gnt.widget.calendar.WeekEditor", {
- extend : "Ext.form.Panel",
- requires : ["Ext.grid.*", "Gnt.data.Calendar", "Sch.util.Date"],
- alias : "widget.calendarweekeditor",
- layout : "anchor",
- defaults : {
- border : false,
- anchor : "100%"
- },
- getDefaultWeekAvailabilityHandler : null,
- startDate : null,
- endDate : null,
- startHeaderText : "Start",
- endHeaderText : "End",
- defaultTimeText : "Default time",
- workingTimeText : "Working time",
- nonworkingTimeText : "Non-working time",
- addText : "Add",
- removeText : "Remove",
- weekAvailability : null,
- currentWeekDay : null,
- _weekDaysGrid : null,
- getWeekDaysGrid : function() {
- if (this._weekDaysGrid != null) {
- return this._weekDaysGrid
- }
- var a = Ext.Date.dayNames;
- return this._weekDaysGrid = Ext.create("Ext.grid.Panel", {
- hideHeaders : true,
- height : 160,
- columns : [{
- header : "",
- dataIndex : "name",
- flex : 1
- }],
- store : Ext.create("Ext.data.JsonStore", {
- fields : ["id", "name"],
- idProperty : "id",
- data : [{
- id : 1,
- name : a[1]
- }, {
- id : 2,
- name : a[2]
- }, {
- id : 3,
- name : a[3]
- }, {
- id : 4,
- name : a[4]
- }, {
- id : 5,
- name : a[5]
- }, {
- id : 6,
- name : a[6]
- }, {
- id : 0,
- name : a[0]
- }]
- }),
- listeners : {
- selectionchange : {
- fn : this.onWeekDaysListSelectionChange,
- scope : this
- }
- }
- })
- },
- _availabilityGrid : null,
- getAvailabilityGrid : function() {
- if (!this._availabilityGrid) {
- this._availabilityGrid = Ext.create("Ext.grid.Panel", {
- height : 160,
- plugins : [Ext.create("Ext.grid.plugin.CellEditing", {
- clicksToEdit : 2
- })],
- tbar : [{
- text : this.addText,
- action : "add",
- handler : this.addAvailability,
- scope : this,
- iconCls : "gnt-action-add"
- }, {
- text : this.removeText,
- iconCls : "gnt-action-remove",
- action : "remove",
- handler : this.removeAvailability,
- scope : this
- }],
- store : Ext.create("Ext.data.Store", {
- fields : ["startTime", "endTime"],
- proxy : {
- type : "memory",
- reader : {
- type : "json"
- }
- }
- }),
- columns : [{
- header : this.startHeaderText,
- xtype : "datecolumn",
- format : "g:i a",
- dataIndex : "startTime",
- flex : 1,
- editor : {
- xtype : "timefield",
- allowBlank : false,
- initDate : "31/12/1899"
- }
- }, {
- header : this.endHeaderText,
- xtype : "datecolumn",
- format : "g:i a",
- dataIndex : "endTime",
- flex : 1,
- editor : {
- allowBlank : false,
- xtype : "timefield",
- initDate : "31/12/1899"
- }
- }],
- listeners : {
- selectionchange : this.onAvailabilityGridSelectionChange,
- scope : this
- }
- })
- }
- return this._availabilityGrid
- },
- getDayTypeRadioGroup : function() {
- return this.down('radiogroup[name="dayType"]')
- },
- initComponent : function() {
- if (!this.getDefaultWeekAvailabilityHandler
- && !Ext.isFunction(this.getDefaultWeekAvailabilityHandler)) {
- Ext.Error
- .raise('Required attribute "getDefaultWeekAvailabilityHandler" is missed during initialization of `Gnt.widget.calendar.WeekEditor`')
- }
- this.items = [{
- xtype : "radiogroup",
- padding : "0 5px",
- name : "dayType",
- items : [{
- boxLabel : this.defaultTimeText,
- name : "IsWorkingDay",
- inputValue : 0
- }, {
- boxLabel : this.workingTimeText,
- name : "IsWorkingDay",
- inputValue : 1
- }, {
- boxLabel : this.nonworkingTimeText,
- name : "IsWorkingDay",
- inputValue : 2
- }],
- listeners : {
- change : {
- fn : this.onDayTypeChanged,
- scope : this
- }
- }
- }, {
- layout : "column",
- padding : "0 0 5px 0",
- defaults : {
- border : false
- },
- items : [{
- margin : "0 10px 0 5px",
- columnWidth : 0.5,
- items : this.getWeekDaysGrid()
- }, {
- columnWidth : 0.5,
- margin : "0 5px 0 0",
- items : this.getAvailabilityGrid()
- }]
- }];
- this.callParent(arguments)
- },
- addAvailability : function() {
- var b = this.getAvailabilityGrid(), a = b.getStore(), c = a.count();
- if (c >= 5) {
- return
- }
- a.add({
- startTime : new Date(0, 0, 0, 12, 0),
- endTime : new Date(0, 0, 0, 13, 0)
- });
- if (c + 1 >= 5) {
- b.down('button[action="add"]').setDisabled(true)
- }
- },
- removeAvailability : function() {
- var c = this.getAvailabilityGrid(), b = c.getStore(), d = b.count(), e = c
- .getSelectionModel();
- if (!e || e.getSelection().length === 0) {
- return
- }
- var a = e.getSelection()[0];
- b.remove(a);
- if (d < 5) {
- c.down('button[action="add"]').setDisabled(false)
- }
- },
- editAvailability : function(b, e, a) {
- this.startDate = b;
- this.endDate = e;
- this.weekAvailability = a;
- var c = this.getWeekDaysGrid(), d = c.getStore().getAt(0);
- c.getSelectionModel().select(d, false, true);
- this.refreshView(d)
- },
- applyChanges : function(a) {
- if (!this.validateAndSave()) {
- return false
- }
- if (a && Ext.isFunction(a)) {
- a.call(this, this.weekAvailability)
- }
- },
- getIntervals : function() {
- var a = [];
- this.getAvailabilityGrid().getStore().each(function(b) {
- a.push({
- startTime : b.get("startTime"),
- endTime : b.get("endTime")
- })
- });
- return a
- },
- onWeekDaysListSelectionChange : function(a, b) {
- if (!this.validateAndSave()) {
- return false
- }
- this.refreshView(b[0])
- },
- validateAndSave : function() {
- var c = this.currentWeekDay.get("IsWorkingDay"), b = [];
- if (c) {
- try {
- b = this.getIntervals();
- this.currentWeekDay.verifyAvailability(b)
- } catch (a) {
- Ext.MessageBox.alert("Error", a);
- return false
- }
- }
- this.currentWeekDay.setAvailability(b);
- return true
- },
- refreshView : function(d) {
- var g = d.getId(), b = this.weekAvailability[g], f = this
- .getDayTypeRadioGroup(), e = b.getAvailability(), c = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/
- .exec(b.getId()), a = !c ? 0 : (b.get("IsWorkingDay") ? 1 : 2);
- this.currentWeekDay = b;
- f.setValue({
- IsWorkingDay : [a]
- });
- this.getAvailabilityGrid().getStore().loadData(e)
- },
- onAvailabilityGridSelectionChange : function(b) {
- var a = this.getAvailabilityGrid();
- a.down('button[action="remove"]').setDisabled(!b
- || b.getSelection().length === 0)
- },
- onDayTypeChanged : function(g) {
- var c = g.getValue();
- if (Ext.isArray(c.IsWorkingDay)) {
- return
- }
- var a = this.getWeekDaysGrid(), d = a.getSelectionModel(), b = d
- .getSelection()[0].getId(), e = this.weekAvailability[b]
- .get("Name"), f = [], i = Ext.Date.format(this.startDate,
- "Y/m/d"), j = Ext.Date.format(this.endDate, "Y/m/d");
- switch (c.IsWorkingDay) {
- case 0 :
- var h = this.getDefaultWeekAvailabilityHandler()[b];
- h.set("Name", e);
- h.set("Date", null);
- f = h.getAvailability();
- this.weekAvailability[b] = h;
- break;
- default :
- f = this.weekAvailability[b].getAvailability();
- this.currentWeekDay.set("Id", Ext.String.format("{0}-{1}-{2}",
- b, i, j));
- this.currentWeekDay.set("IsWorkingDay", c.IsWorkingDay === 1);
- break
- }
- this.getAvailabilityGrid().getStore().loadData(Ext.clone(f));
- this.getAvailabilityGrid().setDisabled(c.IsWorkingDay !== 1)
- }
- });
- Ext.define("Gnt.widget.calendar.DatePicker", {
- extend : "Ext.picker.Date",
- alias : "widget.gntdatepicker",
- calendar : null,
- workingDayCls : "gnt-datepicker-workingday",
- nonWorkingDayCls : "gnt-datepicker-nonworkingday",
- overriddenDayCls : "gnt-datepicker-overriddenday",
- overriddenWeekDayCls : "gnt-datepicker-overriddenweekday",
- _weeks : null,
- getWeekOverrides : function() {
- return this._weeks
- },
- setWeekOverrides : function(a) {
- this._weeks = a
- },
- _days : null,
- getDayOverrides : function() {
- return this._days
- },
- setDayOverrides : function(a) {
- this._days = a
- },
- update : function(b, e) {
- var d = this, c = 0, a = d.cells.elements;
- this.removeCustomCls();
- this.callParent(arguments);
- for (; c < d.numDays; ++c) {
- b = a[c].firstChild.dateValue;
- a[c].className += " " + this.getDateCls(b)
- }
- },
- getDateCls : function(d) {
- var b = "", f = 0, g = this;
- d = new Date(d);
- if (d.getMonth() !== this.getActive().getMonth()) {
- return
- }
- if (this.getDayOverrides().getOverrideDay(d)) {
- b += (" " + this.overriddenDayCls);
- if (!this.getDayOverrides().isWorkingDay(d)) {
- b += (" " + this.nonWorkingDayCls)
- }
- } else {
- var e = null;
- this.getWeekOverrides().each(function(h) {
- if (Ext.Date.between(d, h.getStartDate(), h
- .getEndDate())) {
- e = h;
- return true
- }
- });
- if (e) {
- b += (" " + this.overriddenWeekDayCls);
- var c = new Date(d).getDay(), a = e.getAvailability();
- if (a && a[c] && a[c].getIsWorkingDay() === false) {
- b += (" " + g.nonWorkingDayCls)
- }
- } else {
- if (!this.getDayOverrides().isWorkingDay(d)) {
- b += (" " + this.nonWorkingDayCls)
- }
- }
- }
- return b.length > 0 ? b : this.workingDayCls
- },
- removeCustomCls : function() {
- this.cells.removeCls([this.overriddenDayCls,
- this.nonWorkingDayCls, this.workingDayCls,
- this.overriddenWeekDayCls])
- }
- });
- Ext.define("Gnt.widget.calendar.Calendar", {
- extend : "Ext.form.Panel",
- requires : ["Ext.XTemplate", "Gnt.data.Calendar",
- "Gnt.widget.calendar.DayGrid", "Gnt.widget.calendar.WeekGrid",
- "Gnt.widget.calendar.DayAvailabilityGrid",
- "Gnt.widget.calendar.WeekEditor", "Gnt.widget.calendar.DatePicker"],
- alias : "widget.calendar",
- defaults : {
- padding : 10,
- border : false
- },
- workingDayCls : "gnt-datepicker-workingday",
- nonWorkingDayCls : "gnt-datepicker-nonworkingday",
- overriddenDayCls : "gnt-datepicker-overriddenday",
- overriddenWeekDayCls : "gnt-datepicker-overriddenweekday",
- calendar : null,
- dayOverrideNameHeaderText : "Name",
- dateText : "Date",
- addText : "Add",
- editText : "Edit",
- removeText : "Remove",
- workingDayText : "Working day",
- weekendsText : "Weekends",
- overriddenDayText : "Overridden day",
- overriddenWeekText : "Overridden week",
- defaultTimeText : "Default time",
- workingTimeText : "Working time",
- nonworkingTimeText : "Non-working time",
- dayGridConfig : null,
- weekGridConfig : null,
- datePickerConfig : null,
- dayOverridesText : "Day overrides",
- weekOverridesText : "Week overrides",
- okText : "OK",
- cancelText : "Cancel",
- calendarNameText : "Calendar name",
- tplTexts : {
- tplWorkingHours : "Working hours for",
- tplIsNonWorking : "is non-working",
- tplOverride : "override",
- tplInCalendar : "in calendar",
- tplDayInCalendar : "standard day in calendar"
- },
- parentCalendarText : "Parent calendar",
- noParentText : "No parent",
- selectParentText : "Select parent",
- newDayName : "[Without name]",
- overrideErrorText : "There is already an override for this day",
- intersectDatesErrorText : "Dates shouldn't intersect",
- startDateErrorText : "StartDate greater then EndDate",
- dayGrid : null,
- weekGrid : null,
- getDayGrid : function() {
- if (!this.dayGrid) {
- this.dayGrid = Ext.create("Gnt.widget.calendar.DayGrid", Ext.apply(
- {
- tbar : [{
- text : this.addText,
- action : "add",
- iconCls : "gnt-action-add",
- handler : this.addDay,
- scope : this
- }, {
- text : this.editText,
- action : "edit",
- iconCls : "gnt-action-edit",
- handler : this.editDay,
- scope : this
- }, {
- text : this.removeText,
- action : "remove",
- iconCls : "gnt-action-remove",
- handler : this.removeDay,
- scope : this
- }]
- }, this.dayGridConfig || {}))
- }
- return this.dayGrid
- },
- getWeekGrid : function() {
- if (!this.weekGrid) {
- this.weekGrid = Ext.create("Gnt.widget.calendar.WeekGrid", Ext
- .apply({
- tbar : [{
- text : this.addText,
- action : "add",
- iconCls : "gnt-action-add",
- handler : this.addWeek,
- scope : this
- }, {
- text : this.editText,
- action : "edit",
- iconCls : "gnt-action-edit",
- handler : this.editWeek,
- scope : this
- }, {
- text : this.removeText,
- action : "remove",
- iconCls : "gnt-action-remove",
- handler : this.removeWeek,
- scope : this
- }]
- }, this.weekGridConfig || {}))
- }
- return this.weekGrid
- },
- datePicker : null,
- getDatePicker : function() {
- if (!this.datePicker) {
- this.datePicker = Ext.create("Gnt.widget.calendar.DatePicker",
- this.datePickerConfig || {})
- }
- return this.datePicker
- },
- legendTpl : '<ul class="gnt-calendar-legend"><li class="gnt-calendar-legend-item"><div class="gnt-calendar-legend-itemstyle {workingDayCls}"></div><span class="gnt-calendar-legend-itemname">{workingDayText}</span><div style="clear: both"></div></li><li><div class="gnt-calendar-legend-itemstyle {nonWorkingDayCls}"></div><span class="gnt-calendar-legend-itemname">{weekendsText}</span><div style="clear: both"></div></li><li class="gnt-calendar-legend-override"><div class="gnt-calendar-legend-itemstyle {overriddenDayCls}">31</div><span class="gnt-calendar-legend-itemname">{overriddenDayText}</span><div style="clear: both"></div></li><li class="gnt-calendar-legend-override"><div class="gnt-calendar-legend-itemstyle {overriddenWeekDayCls}">31</div><span class="gnt-calendar-legend-itemname">{overriddenWeekText}</span><div style="clear: both"></div></li></ul>',
- dateInfoTpl : null,
- initComponent : function() {
- var d = this;
- if (!(this.legendTpl instanceof Ext.Template)) {
- this.legendTpl = new Ext.XTemplate(this.legendTpl)
- }
- if (!(this.dateInfoTpl instanceof Ext.Template)) {
- this.dateInfoTpl = new Ext.XTemplate(this.dateInfoTpl)
- }
- if (!this.calendar) {
- Ext.Error
- .raise('Required attribute "calendar" is missed during initialization of `Gnt.widget.Calendar`')
- }
- d.setupTemplates();
- var b = this.getWeekGrid(), a = this.getDayGrid(), c = this
- .getDatePicker();
- this.dayGrid.on({
- selectionchange : this.onDayGridSelectionChange,
- validateedit : this.onDayGridValidateEdit,
- edit : this.onDayGridEdit,
- scope : this
- });
- this.dayGrid.store.on({
- update : this.refreshView,
- remove : this.refreshView,
- add : this.refreshView,
- scope : this
- });
- this.weekGrid.on({
- selectionchange : this.onWeekGridSelectionChange,
- validateedit : this.onWeekGridValidateEdit,
- edit : this.onWeekGridEdit,
- scope : this
- });
- this.weekGrid.store.on({
- update : this.refreshView,
- remove : this.refreshView,
- add : this.refreshView,
- scope : this
- });
- this.datePicker.on({
- select : this.onDateSelect,
- scope : this
- });
- this.fillDaysStore();
- this.fillWeeksStore();
- c.setWeekOverrides(b.getStore());
- c.setDayOverrides(a.getStore());
- this.dateInfoPanel = new Ext.Panel({
- cls : "gnt-calendar-dateinfo",
- columnWidth : 0.33,
- border : false,
- height : 200
- });
- this.items = [{
- xtype : "container",
- layout : "hbox",
- pack : "start",
- align : "stretch",
- items : [{
- html : Ext.String.format('{0}: "{1}"', this.calendarNameText,
- this.calendar.name),
- border : false,
- flex : 1
- }, {
- xtype : "combobox",
- name : "cmb_parentCalendar",
- fieldLabel : d.parentCalendarText,
- store : Ext.create("Ext.data.Store", {
- fields : ["Id", "Name"],
- data : [{
- Id : -1,
- Name : d.noParentText
- }].concat(d.calendar
- .getParentableCalendars())
- }),
- queryMode : "local",
- displayField : "Name",
- valueField : "Id",
- editable : false,
- emptyText : d.selectParentText,
- value : d.calendar.parent ? d.calendar.parent.calendarId : -1,
- flex : 1
- }]
- }, {
- layout : "column",
- defaults : {
- border : false
- },
- items : [{
- margin : "0 15px 0 0",
- columnWidth : 0.3,
- html : this.legendTpl.apply({
- workingDayText : this.workingDayText,
- weekendsText : this.weekendsText,
- overriddenDayText : this.overriddenDayText,
- overriddenWeekText : this.overriddenWeekText,
- workingDayCls : this.workingDayCls,
- nonWorkingDayCls : this.nonWorkingDayCls,
- overriddenDayCls : this.overriddenDayCls,
- overriddenWeekDayCls : this.overriddenWeekDayCls
- })
- }, {
- columnWidth : 0.37,
- margin : "0 5px 0 0",
- items : c
- }, this.dateInfoPanel]
- }, {
- xtype : "tabpanel",
- items : [a, b]
- }];
- this.callParent(arguments)
- },
- setupTemplates : function() {
- var a = this, b = [a.tplTexts[0], a.tplTexts[1], a.tplTexts[2],
- a.tplTexts[3], a.tplTexts[4]];
- this.dateInfoTpl = this.dateInfoTpl
- || Ext.String.format(['<tpl if="isWorkingDay == true">',
- "<div>{0} {date}:</div>", "</tpl>",
- '<tpl if="isWorkingDay == false">',
- "<div>{date} {1}</div>", "</tpl>",
- '<ul class="gnt-calendar-availabilities">',
- '<tpl for="availability">', "<li>{.}</li>",
- "</tpl>", "</ul>", "<span>Based on: ",
- '<tpl if="override == true">',
- '{2} "{name}" {3} "{calendarName}"', "</tpl>",
- '<tpl if="override == false">',
- '{4} "{calendarName}"', "</tpl>", "</span>"]
- .join(""), b)
- },
- onRender : function() {
- this.onDateSelect(this.getDatePicker(), new Date());
- this.callParent(arguments)
- },
- fillDaysStore : function() {
- var a = [];
- this.calendar.each(function(b) {
- if (!b.getDate()) {
- return
- }
- a.push(Ext.create("Gnt.model.CalendarDay", {
- Date : b.getDate(),
- Id : b.getId(),
- Name : b.getName(),
- IsWorkingDay : b.getIsWorkingDay(),
- Availability : b.getAvailability()
- }))
- });
- this.getDayGrid().getStore().loadData(a)
- },
- fillWeeksStore : function() {
- var d = [], c = this, b = this.getWeekGrid().store.model.prototype, a;
- Ext.Array.each(this.calendar.nonStandardWeeksStartDates, function(f) {
- var h = c.calendar.getNonStandardWeekByStartDate(f);
- var g = {};
- var e = c.calendar.getDefaultWeekAvailability();
- g[b.nameField] = h.name;
- g[b.startDateField] = h.startDate;
- g[b.endDateField] = h.endDate;
- g[b.availabilityField] = e;
- Ext.Array.each(e, function(i) {
- i.setName(h.name);
- i.clearDate(null)
- });
- Ext.Array.each(h.weekAvailability, function(k, l) {
- if (k) {
- var m = k.getId();
- var j = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/
- .exec(m);
- if (!j) {
- return
- }
- var i = j[1];
- a = Ext.create("Gnt.model.CalendarDay");
- a.clearDate(null);
- a.setId(m);
- a.setName(h.name);
- a.setIsWorkingDay(k.getIsWorkingDay());
- a.setAvailability(k.getAvailability())
- } else {
- a = c.calendar.getDefaultCalendarDay(l)
- }
- e[l] = a
- });
- d.push(g)
- });
- this.getWeekGrid().getStore().loadData(d)
- },
- reload : function() {
- var b = this.getWeekGrid(), a = this.getDayGrid();
- this.fillDaysStore();
- this.fillWeeksStore();
- this.getDatePicker().setWeekOverrides(b.getStore());
- this.getDatePicker().setDayOverrides(a.getStore())
- },
- editDay : function() {
- var c = this, e = this.getDayGrid().getSelectionModel();
- if (!e || e.getSelection().length === 0) {
- return
- }
- var a = e.getSelection()[0];
- var b = new Gnt.widget.calendar.DayAvailabilityGrid({
- addText : this.addText,
- removeText : this.removeText,
- workingTimeText : this.workingTimeText,
- nonworkingTimeText : this.nonworkingTimeText
- });
- var d = Ext.create("Ext.window.Window", {
- title : this.dayOverridesText,
- modal : true,
- width : 280,
- height : 260,
- layout : "fit",
- items : b,
- buttons : [{
- text : this.okText,
- handler : function() {
- c.calendar.clearCache();
- if (b.isValid()) {
- var f = b.calendarDay;
- f.setIsWorkingDay(b.isWorkingDay());
- f.setAvailability(b.getIntervals());
- c.applyCalendarDay(f, a);
- c.refreshView();
- d.close()
- }
- }
- }, {
- text : this.cancelText,
- handler : function() {
- d.close()
- }
- }]
- });
- b.editAvailability(this.cloneCalendarDay(a));
- d.show()
- },
- addDay : function() {
- var a = this.getDatePicker().getValue(), b = this.getDayGrid(), c = Ext
- .create("Gnt.model.CalendarDay", {
- Name : this.newDayName,
- Cls : this.calendar.defaultNonWorkingTimeCssCls,
- Date : a,
- IsWorkingDay : false
- });
- b.getStore().insert(0, c);
- b.getSelectionModel().select([c], false, false)
- },
- removeDay : function() {
- var f = this.getDayGrid(), h = f.getSelectionModel(), c = f.getStore();
- if (!h || h.getSelection().length === 0) {
- return
- }
- c.clearCache();
- var a = h.getSelection()[0], d = this.getDatePicker().getValue(), g = d
- .getDay(), b = this.getWeekOverrideDay(d), e = b != null;
- c.remove(a);
- if (b == null) {
- b = this.calendar.defaultWeekAvailability[g]
- }
- this.getDatePicker().setValue(d)
- },
- refreshView : function() {
- var e = this.getDatePicker().getValue(), b = this.getCalendarDay(e), d = this
- .getWeekGrid(), a = this.getDayGrid(), c = a.getStore()
- .getOverrideDay(e), g;
- if (c) {
- a.getSelectionModel().select([c], false, true)
- } else {
- g = this.getWeekOverrideByDate(e);
- if (g) {
- d.getSelectionModel().select([g], false, true)
- }
- }
- var f = {
- name : b.getName(),
- date : Ext.Date.format(e, "M j, Y"),
- calendarName : this.calendar.name || this.calendar.calendarId,
- availability : b.getAvailability(true),
- override : !!(c || g),
- isWorkingDay : b.getIsWorkingDay()
- };
- this.dateInfoPanel.update(this.dateInfoTpl.apply(f))
- },
- onDayGridSelectionChange : function(d) {
- if (!d || d.getSelection().length === 0) {
- return
- }
- var a = d.getSelection()[0], b = a.getDate(), c = this.getDayGrid();
- this.getDatePicker().setValue(b)
- },
- onDayGridEdit : function(b, c) {
- if (c.field === "Date") {
- var a = Ext.Date.clearTime(c.value, true);
- c.record.data[c.record.idProperty] = a - 0;
- c.grid.getStore().clearCache();
- this.getDatePicker().setValue(c.value)
- }
- this.refreshView()
- },
- onDayGridValidateEdit : function(b, c) {
- var a = c.grid.getStore();
- if (c.field === a.model.prototype.dateField
- && a.getOverrideDay(c.value) && c.value !== c.originalValue) {
- Ext.MessageBox.alert("Error", this.overrideErrorText);
- return false
- }
- },
- onDateSelect : function(b, a) {
- this.refreshView()
- },
- getCalendarDay : function(b) {
- var a = this.getOverrideDay(b);
- if (a) {
- return a
- }
- a = this.getWeekOverrideDay(b);
- if (a) {
- return a
- }
- return this.calendar.defaultWeekAvailability[b.getDay()]
- },
- getOverrideDay : function(a) {
- return this.getDayGrid().getStore().getOverrideDay(a)
- },
- getWeekOverrideDay : function(c) {
- var e = new Date(c), d = this.getWeekOverrideByDate(c), b = e.getDay();
- if (d == null) {
- return null
- }
- var a = d.getAvailability();
- if (!a) {
- return null
- }
- return a[b]
- },
- getWeekOverrideByDate : function(a) {
- var b = null;
- this.getWeekGrid().getStore().each(function(c) {
- if (Ext.Date.between(a, c.getStartDate(), c.getEndDate())) {
- b = c;
- return true
- }
- });
- return b
- },
- editWeek : function() {
- var f = this.getWeekGrid().getSelectionModel(), c = this;
- if (!f || f.getSelection().length === 0) {
- return
- }
- var b = f.getSelection()[0];
- var a = new Gnt.widget.calendar.WeekEditor({
- getDefaultWeekAvailabilityHandler : function() {
- return c.getDefaultWeekAvailability()
- }
- });
- var e = Ext.create("Ext.window.Window", {
- title : this.weekOverridesText,
- modal : true,
- width : 370,
- defaults : {
- border : false
- },
- layout : "fit",
- items : a,
- buttons : [{
- text : this.okText,
- handler : function() {
- c.calendar.clearCache();
- a.applyChanges(function(g) {
- b.setAvailability(g);
- var i = c.getDatePicker().getValue(), h = g[i.getDay()];
- c.refreshView();
- e.close()
- })
- }
- }, {
- text : this.cancelText,
- handler : function() {
- e.close()
- }
- }]
- });
- var d = [];
- Ext.Array.each(b.getAvailability(), function(g) {
- d.push(c.cloneCalendarDay(g))
- });
- e.show();
- e.down("calendarweekeditor").editAvailability(b.getStartDate(),
- b.getEndDate(), d)
- },
- addWeek : function() {
- var a = this.getWeekGrid().getStore();
- var b = this.getDatePicker().getValue(), c = new a.model();
- c.setName(this.newDayName);
- c.setStartDate(b);
- c.setEndDate(b);
- c.setAvailability(this.calendar.getDefaultWeekAvailability());
- a.insert(0, c);
- this.getWeekGrid().getSelectionModel().select([c], false, false)
- },
- removeWeek : function() {
- var f = this.getWeekGrid().getSelectionModel();
- if (!f || f.getSelection().length === 0) {
- return
- }
- var a = f.getSelection()[0], c = this.getDatePicker().getValue(), e = c
- .getDay(), b = this.getOverrideDay(c), d = !!b;
- b = b || this.calendar.defaultWeekAvailability[e];
- this.getWeekGrid().getStore().remove(a);
- this.getDatePicker().setValue(c);
- this.refreshView()
- },
- onWeekGridSelectionChange : function(c) {
- if (!c || c.getSelection().length === 0) {
- return
- }
- var a = c.getSelection()[0], b = a.getStartDate();
- this.getDatePicker().setValue(b)
- },
- onWeekGridEdit : function(f, g) {
- var c = g.record, a = c.getStartDate(), d = c.getEndDate(), b = c
- .getAvailability(), j = g.grid.getStore().model.prototype;
- if (g.field == j.startDateField || g.field == j.endDateField) {
- var h = Ext.Date.format(a, "Y/m/d");
- var i = Ext.Date.format(d, "Y/m/d");
- Ext.Array.each(b, function(k) {
- var l = k.getId();
- var e = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/
- .exec(l);
- if (!e) {
- return
- }
- k.set("Id", Ext.String
- .format("{0}-{1}-{2}", e[1], h, i))
- });
- this.getDatePicker().setValue(a)
- }
- this.refreshView()
- },
- onWeekGridValidateEdit : function(d, f) {
- var g = this, b = f.record, a = b.getStartDate(), c = b.getEndDate(), h = true, i = f.grid
- .getStore(), j = i.model.prototype;
- if ((f.field === j.startDateField && c < f.value || f.field === j.endDateField
- && a > f.value)) {
- Ext.MessageBox.alert("Error", g.startDateErrorText);
- return false
- }
- i.each(function(k) {
- var l = k.getStartDate(), e = k.getEndDate();
- if (l == a && e == c) {
- return
- }
- if ((f.field == j.startDateField && l < a && f.value <= e)
- || (f.field == j.endDateField && e > c && f.value >= l)) {
- h = false;
- return true
- }
- });
- if (!h) {
- Ext.MessageBox.alert("Error", g.intersectDatesErrorText);
- return false
- }
- },
- applyChanges : function(b) {
- var a = this.down('combobox[name="cmb_parentCalendar"]').getValue();
- this.calendar.parent = a ? Gnt.data.Calendar.getCalendar(a) : null;
- this.calendar.proxy.extraParams.parentId = this.calendar.parent
- ? this.calendar.parent.calendarId
- : null;
- this.applyDays();
- this.applyWeeks();
- if (b && Ext.isFunction(b)) {
- b.call(this, this.calendar)
- }
- },
- applyCalendarDay : function(b, a) {
- a.beginEdit();
- a.setId(b.getId());
- a.setName(b.getName());
- a.setIsWorkingDay(b.getIsWorkingDay());
- a.setDate(b.getDate());
- a.setAvailability(b.getAvailability());
- a.endEdit()
- },
- applyWeek : function(d, c) {
- var b = this, a = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/;
- Ext.Array.each(d.getAvailability(), function(f, h) {
- var i = false, g = f.getId(), e = a.exec(g) ? false : true;
- Ext.Array.each(c.weekAvailability, function(j) {
- var l = j.getId(), k = a.exec(l);
- if (k[1] == h) {
- if (e) {
- b.calendar.remove(j)
- } else {
- b.applyCalendarDay(f, j)
- }
- i = true;
- return i
- }
- });
- if (!i && !e) {
- b.calendar.add(f)
- }
- })
- },
- applyWeeks : function() {
- var c = this, b = this.getWeekGrid().getStore(), a = [], e = [], d = [];
- Ext.Array.each(this.calendar.nonStandardWeeksStartDates, function(f) {
- var g = false;
- b.each(function(i) {
- var h = Ext.Date.clearTime(i.getStartDate());
- if (h === f) {
- var j = c.calendar
- .getNonStandardWeekByDate(f);
- j.endDate == i.getEndDate() ? e
- .push([i, j]) : a.push(f);
- g = true;
- return true
- }
- });
- if (!g) {
- a.push(f)
- }
- });
- b.each(function(f) {
- if (c.calendar
- .getNonStandardWeekByDate(f.getStartDate() == null)) {
- d.push(f)
- }
- });
- Ext.Array.each(a, function(f) {
- c.calendar.removeNonStandardWeek(f)
- });
- Ext.Array.each(d, function(f) {
- c.calendar.addNonStandardWeek(f.getStartDate(), f
- .getEndDate(), f.getAvailability())
- });
- Ext.Array.each(e, function(f) {
- c.applyWeek(f[0], f[1])
- })
- },
- applyDays : function() {
- var c = this, b = this.getDayGrid().getStore(), a = [], e = [], d = [];
- this.calendar.each(function(f) {
- var g = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/
- .exec(f.getId());
- if (g) {
- return
- }
- b.getOverrideDay(f.getDate()) == null ? a.push(f) : e
- .push(f)
- });
- b.each(function(f) {
- if (c.calendar.getOverrideDay(f.getDate()) == null) {
- d.push(f)
- }
- });
- this.calendar.remove(a);
- this.calendar.add(d);
- Ext.Array.each(e, function(f) {
- var g = b.getOverrideDay(f.getDate());
- c.applyCalendarDay(g, f)
- })
- },
- cloneCalendarDay : function(a) {
- return Ext.create("Gnt.model.CalendarDay", {
- Date : a.getDate(),
- Id : a.getId(),
- Name : a.getName(),
- IsWorkingDay : a.getIsWorkingDay(),
- Availability : a.getAvailability()
- })
- },
- getDefaultWeekAvailability : function() {
- return this.calendar.defaultWeekAvailability
- },
- onDestroy : function() {
- this.getWeekGrid().destroy();
- this.getDayGrid().destroy();
- this.getDatePicker().destroy();
- this.callParent(arguments)
- }
- });
- /*Ext.onReady(function() {
- if (window.location.href.match("bryntum.com|ext-scheduler.com")) {
- return
- } else {
- if (Sch && Sch.view && Sch.view.TimelineGridView) {
- var b = false;
- Sch.view.TimelineGridView.override({
- refresh : function() {
- this.callOverridden(arguments);
- if (b || !this.rendered) {
- return
- }
- b = true;
- Ext.Function.defer(function() {
- this.el.select(this.eventSelector)
- .setOpacity(0.15)
- }, 10 * 60 * 1000, this);
- var c = this.el.parent().createChild({
- tag : "a",
- href : "http://www.bryntum.com/store",
- title : "Click here to purchase a license",
- style : "display:block;height:54px;width:230px;background: #fff url(http://www.bryntum.com/site-images/bryntum-trial.png) no-repeat;z-index:10000;border:1px solid #ddd;-webkit-box-shadow: 2px 2px 2px rgba(100, 100, 100, 0.5);-moz-box-shadow: 2px 2px 2px rgba(100, 100, 100, 0.5);-moz-border-radius:5px;-webkit-border-radius:5px;position:absolute;bottom:10px;right:15px;"
- });
- try {
- if (!Ext.util.Cookies.get("bmeval")) {
- Ext.util.Cookies.set("bmeval",
- new Date().getTime(), Ext.Date.add(
- new Date(), Ext.Date.YEAR, 2))
- } else {
- var g = Ext.util.Cookies.get("bmeval"), d = new Date(parseInt(
- g, 10));
- if (Ext.Date.add(d, Ext.Date.DAY, 45) < new Date()) {
- this.el.select(this.eventSelector).hide();
- this.el.mask("Trial Period Expired!").setStyle(
- "z-index", 10000);
- this.refresh = Ext.emptyFn
- }
- }
- } catch (f) {
- }
- }
- })
- }
- if (Sch && Sch.view && Sch.view.TimelineTreeView) {
- var a = false;
- Sch.view.TimelineTreeView.override({
- refresh : function() {
- this.callOverridden(arguments);
- if (a || !this.rendered) {
- return
- }
- a = true;
- Ext.Function.defer(function() {
- this.el.select(this.eventSelector)
- .setOpacity(0.15)
- }, 10 * 60 * 1000, this);
- var c = this.el.parent().createChild({
- tag : "a",
- href : "http://www.bryntum.com/store",
- title : "Click here to purchase a license",
- style : "display:block;height:54px;width:230px;background: #fff url(http://www.bryntum.com/site-images/bryntum-trial.png) no-repeat;z-index:10000;border:1px solid #ddd;-webkit-box-shadow: 2px 2px 2px rgba(100, 100, 100, 0.5);-moz-box-shadow: 2px 2px 2px rgba(100, 100, 100, 0.5);-moz-border-radius:5px;-webkit-border-radius:5px;position:absolute;bottom:10px;right:15px;"
- });
- Ext.Function.defer(c.fadeOut, 10000, c);
- try {
- if (!Ext.util.Cookies.get("bmeval")) {
- Ext.util.Cookies.set("bmeval",
- new Date().getTime(), Ext.Date.add(
- new Date(), Ext.Date.YEAR, 2))
- } else {
- var g = Ext.util.Cookies.get("bmeval"), d = new Date(parseInt(
- g, 10));
- if (Ext.Date.add(d, Ext.Date.DAY, 45) < new Date()) {
- this.el.select(this.eventSelector).hide();
- this.el.mask("Trial Period Expired!").setStyle(
- "z-index", 10000);
- this.refresh = Ext.emptyFn
- }
- }
- } catch (f) {
- }
- }
- })
- }
- }
- });*/
- Ext.data.Connection.override({
- parseStatus : function(b) {
- var a = this.callOverridden(arguments);
- if (b === 0) {
- a.success = true
- }
- return a
- }
- });
|