@@ -559,69 +559,7 @@ <h5 class="text-center" th:text="#{t_similar_series}">
559
559
/*/-->
560
560
</ div >
561
561
562
- < div class ="row " th:if ="${not #lists.isEmpty(purchasesAndSales)} " sec:authorize ="hasAuthority('VIEW_SERIES_SALES') ">
563
- < div class ="col-sm-12 ">
564
- < h5 th:text ="#{t_who_selling_series} "> Who was selling/buying this series</ h5 >
565
- < ul th:remove ="all-but-first ">
566
- < li id ="series-sale-1-info "
567
- th:id ="|series-sale-${iter.count}-info| "
568
- th:each ="transaction,iter : ${purchasesAndSales} "
569
- th:with ="firstPrice=${#numbers.formatDecimal(transaction.firstPrice, 0, 'DEFAULT', 2, 'DEFAULT') + ' ' + transaction.firstCurrency},
570
- optionalSecondPrice=${transaction.secondPrice != null ? (' ' + '(' + #numbers.formatDecimal(transaction.secondPrice, 0, 'DEFAULT', 2, 'DEFAULT') + ' ' + transaction.secondCurrency + ')') : ''} ">
571
- <!--/*/
572
- <span th:if="${transaction.date != null}" th:remove="tag" th:text="${#dates.format(transaction.date, 'dd.MM.yyyy')}"></span>
573
- /*/-->
574
- < a href ="http://example.com/james-alan-hetfield "
575
- id ="series-sale-1-seller "
576
- rel ="nofollow "
577
- th:id ="|series-sale-${iter.count}-seller| "
578
- th:remove ="${transaction.sellerUrl == null} ? tag "
579
- th:href ="${transaction.sellerUrl} "
580
- th:text ="${transaction.sellerName} "> James Alan Hetfield</ a >
581
- < span th:if ="${transaction.buyerName == null} " th:remove ="tag " th:text ="#{t_was_selling_for} "> was selling for</ span >
582
- <!--/*/
583
- <th:block th:if="${transaction.buyerName != null}">
584
- <span th:text="#{t_sold_to}" th:remove="tag">sold to</span>
585
- <a href="http://example.com/eicca-toppinen" rel="nofollow" th:remove="${transaction.buyerUrl == null} ? tag" th:href="${transaction.buyerUrl}" th:text="${transaction.buyerName}">Eicca Toppinen</a>
586
- <span th:text="#{t_sold_for}" th:remove="tag">for</span>
587
- </th:block>
588
- /*/-->
589
- < a href ="http://example.com/james-alan-hetfield/selling-stamps "
590
- id ="series-sale-1-transaction "
591
- rel ="nofollow "
592
- th:id ="|series-sale-${iter.count}-transaction| "
593
- th:remove ="${transaction.transactionUrl == null} ? tag "
594
- th:href ="${transaction.transactionUrl} "
595
- th:text ="${firstPrice + optionalSecondPrice} "> 100 USD</ a >
596
- <!--/*/
597
- <th:block th:if="${transaction.condition != null}" th:switch="${transaction.condition.toString()}">
598
- <span th:text="|(${#strings.unCapitalize('__#{t_cancelled}__')})|" th:case=" 'CANCELLED' ">cancelled</span>
599
- /*/-->
600
- < span th:text ="|(${transaction.condition})| " th:case ="* "> (MNH)</ span >
601
- <!--/*/
602
- </th:block>
603
- /*/-->
604
- </ li >
605
- < li id ="series-sale-2-info ">
606
- < a href ="http://example.com/james-alan-hetfield " id ="series-sale-2-seller " rel ="nofollow "> James Alan Hetfield</ a > was selling for < a href ="http://example.com/james-alan-hetfield/selling-stamps " id ="series-sale-2-transaction " rel ="nofollow "> 100 USD (650 RUB)</ a >
607
- </ li >
608
- < li id ="series-sale-3-info ">
609
- 02.02.2002 < a href ="http://example.com/tommy-lee-jones " id ="series-sale-3-seller " rel ="nofollow "> Tommy Lee Jones</ a > was selling for < a href ="http://example.com/tommy-lee-jones/selling-stamps " id ="series-sale-3-transaction " rel ="nofollow "> 200 USD</ a >
610
- (cancelled)
611
- </ li >
612
- < li id ="series-sale-4-info ">
613
- 02.02.2002 < a href ="http://example.com/tommy-lee-jones " id ="series-sale-4-seller " rel ="nofollow "> Tommy Lee Jones</ a > was selling for < a href ="http://example.com/tommy-lee-jones/selling-stamps " id ="series-sale-4-transaction " rel ="nofollow "> 200 USD (1300 RUB)</ a >
614
- </ li >
615
- < li id ="series-sale-5-info ">
616
- 03.03.2003 < a href ="http://example.com/eicca-toppinen " id ="series-sale-5-seller " rel ="nofollow "> Eicca Toppinen</ a > sold to < a href ="http://example.com/kurt-cobain " rel ="nofollow "> Kurt Cobain</ a > for < a href ="http://example.com/eicca-toppinen/selling-stamps " id ="series-sale-5-transaction " rel ="nofollow "> 300 USD</ a >
617
- (MVLH)
618
- </ li >
619
- < li id ="series-sale-6-info ">
620
- 03.03.2003 < a href ="http://example.com/eicca-toppinen " id ="series-sale-6-seller " rel ="nofollow "> Eicca Toppinen</ a > sold to Michael Jackson for < a href ="http://example.com/eicca-toppinen/selling-stamps " id ="series-sale-6-transaction " rel ="nofollow "> 300 USD (1560 RUB)</ a >
621
- </ li >
622
- </ ul >
623
- </ div >
624
- </ div >
562
+ < div id ="series-sales-list " sec:authorize ="hasAuthority('VIEW_SERIES_SALES') "> </ div >
625
563
626
564
< div class ="row " sec:authorize ="hasAuthority('ADD_SERIES_SALES') ">
627
565
< div class ="col-sm-12 ">
@@ -999,6 +937,107 @@ <h5 th:text="#{t_add_info_who_selling_series}">Add info about selling/buying thi
999
937
1000
938
responseCount ++ ;
1001
939
940
+ return new Promise ( function delayExecution ( resolve ) {
941
+ setTimeout ( resolve , 500 /* 0.5 second */ ) ;
942
+
943
+ } ) . then ( function returnResponse ( ) {
944
+ return stubResponse . status == 500 ? Promise . reject ( stubResponse ) : Promise . resolve ( stubResponse ) ;
945
+ } ) ;
946
+ } ,
947
+ get : function ( url ) {
948
+ var possibleOutcomes = [ 'success' ] ;
949
+ var outcome = possibleOutcomes [ responseCount % possibleOutcomes . length ] ;
950
+ var possibleResponses = {
951
+ '/series/100' : {
952
+ 'success' : {
953
+ status : 200 ,
954
+ data : [
955
+ {
956
+ id : 1 ,
957
+ sellerName : 'James Alan Hetfield' ,
958
+ sellerUrl : 'http://example.com/james-alan-hetfield' ,
959
+ buyerName : 'Eicca Toppinen' ,
960
+ buyerUrl : 'http://example.com/eicca-toppinen' ,
961
+ transactionUrl : 'http://example.com/james-alan-hetfield/selling-stamps' ,
962
+ firstPrice : 100 ,
963
+ firstCurrency : 'USD' ,
964
+ condition : 'CANCELLED'
965
+ } ,
966
+ {
967
+ id : 2 ,
968
+ sellerName : 'James Alan Hetfield' ,
969
+ sellerUrl : 'http://example.com/james-alan-hetfield' ,
970
+ transactionUrl : 'http://example.com/james-alan-hetfield/selling-stamps' ,
971
+ firstPrice : 100 ,
972
+ firstCurrency : 'USD' ,
973
+ secondPrice : 650 ,
974
+ secondCurrency : 'RUB' ,
975
+ condition : 'CANCELLED'
976
+ } ,
977
+ {
978
+ id : 3 ,
979
+ date : '02.02.2002' ,
980
+ sellerName : 'Tommy Lee Jones' ,
981
+ sellerUrl : 'http://example.com/tommy-lee-jones' ,
982
+ transactionUrl : 'http://example.com/tommy-lee-jones/selling-stamps' ,
983
+ firstPrice : 200 ,
984
+ firstCurrency : 'USD' ,
985
+ condition : 'MNH'
986
+ } ,
987
+ {
988
+ id : 4 ,
989
+ date : '02.02.2002' ,
990
+ sellerName : 'Tommy Lee Jones' ,
991
+ sellerUrl : 'http://example.com/tommy-lee-jones' ,
992
+ transactionUrl : 'http://example.com/tommy-lee-jones/selling-stamps' ,
993
+ firstPrice : 200 ,
994
+ firstCurrency : 'USD' ,
995
+ secondPrice : 1300 ,
996
+ secondCurrency : 'RUB' ,
997
+ } ,
998
+ {
999
+ id : 5 ,
1000
+ date : '03.02.2002' ,
1001
+ sellerName : 'Eicca Toppinen' ,
1002
+ sellerUrl : 'http://example.com/eicca-toppinen' ,
1003
+ transactionUrl : 'http://example.com/tommy-lee-jones/selling-stamps' ,
1004
+ firstPrice : 300 ,
1005
+ firstCurrency : 'USD' ,
1006
+ secondPrice : 1560 ,
1007
+ secondCurrency : 'RUB' ,
1008
+ } ,
1009
+ {
1010
+ id : 6 ,
1011
+ date : '03.02.2002' ,
1012
+ sellerName : 'Eicca Toppinen' ,
1013
+ sellerUrl : 'http://example.com/eicca-toppinen' ,
1014
+ buyerName : 'Kurt Cobain' ,
1015
+ buyerUrl : 'http://example.com/kurt-cobain' ,
1016
+ transactionUrl : 'http://example.com/tommy-lee-jones/selling-stamps' ,
1017
+ firstPrice : 300 ,
1018
+ firstCurrency : 'USD' ,
1019
+ secondPrice : 1560 ,
1020
+ secondCurrency : 'RUB' ,
1021
+ }
1022
+ ]
1023
+ }
1024
+ }
1025
+ } ;
1026
+ var stubResponse ;
1027
+
1028
+ switch ( outcome ) {
1029
+ case 'success' :
1030
+ stubResponse = possibleResponses [ url ] [ outcome ] ;
1031
+ break ;
1032
+ default :
1033
+ stubResponse = {
1034
+ status : 500 ,
1035
+ statusText : 'Fake Server Error'
1036
+ } ;
1037
+ }
1038
+
1039
+ responseCount ++ ;
1040
+
1002
1041
return new Promise ( function delayExecution ( resolve ) {
1003
1042
setTimeout ( resolve , 500 /* 0.5 second */ ) ;
1004
1043
@@ -1019,6 +1058,8 @@ <h5 th:text="#{t_add_info_who_selling_series}">Add info about selling/buying thi
1019
1058
< script src ="../../../../../../target/classes/js/components/AddReleaseYearForm.js " th:src ="${RELEASE_YEAR_FORM_JS} "> </ script >
1020
1059
< script src ="../../../../../../target/classes/js/components/AddCatalogPriceForm.js " th:src ="${CATALOG_PRICE_FORM_JS} "> </ script >
1021
1060
< script src ="../../../../../../target/classes/js/components/AddCatalogNumbersForm.js " th:src ="${CATALOG_NUMBERS_FORM_JS} "> </ script >
1061
+ < script src ="../../../../../../target/classes/js/components/SeriesSalesList.js " th:src ="${SERIES_SALES_LIST_JS} "> </ script >
1062
+
1022
1063
1023
1064
< script th:inline ="javascript ">
1024
1065
/*[+
@@ -1057,6 +1098,12 @@ <h5 th:text="#{t_add_info_who_selling_series}">Add info about selling/buying thi
1057
1098
't_add': [[ #{t_add} ]]
1058
1099
}
1059
1100
};
1101
+ var seriesSalesListProps = {
1102
+ 'url': [[ '__@{${INFO_SERIES_PAGE}(id=${series.id})}__' ]],
1103
+ 'l10n': {
1104
+ 't_server_error': [[ #{t_server_error} ]],
1105
+ }
1106
+ };
1060
1107
+]*/
1061
1108
1062
1109
/*[- */
@@ -1074,10 +1121,17 @@ <h5 th:text="#{t_add_info_who_selling_series}">Add info about selling/buying thi
1074
1121
'url' : '/series/100' ,
1075
1122
'l10n' : { }
1076
1123
} ;
1124
+
1125
+ var seriesSalesListProps = {
1126
+ 'url' : '/series/100' ,
1127
+ 'l10n' : { }
1128
+ } ;
1077
1129
/* -]*/
1078
1130
1079
1131
renderComponent ( AddCatalogPriceForm , addCatalogPriceProps , 'add-catalog-price' ) ;
1080
1132
renderComponent ( AddCatalogNumbersForm , addCatalogNumbersProps , 'add-catalog-numbers' ) ;
1133
+ renderComponent ( SeriesSalesList , seriesSalesListProps , 'series-sales-list' ) ;
1134
+
1081
1135
1082
1136
/*[# th:if="${series.releaseYear == null}"]*/
1083
1137
/*[+
0 commit comments