Skip to content

Commit 39448d6

Browse files
authored
Merge pull request #3 from Indie-Kimura/W-OA-15-3.1.2
W oa 15 3.1.2
2 parents 45eefc8 + 22edbdd commit 39448d6

5 files changed

Lines changed: 299 additions & 21 deletions

File tree

app-author-add/src/app/app.component.html

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ <h5>
1313
</h5>
1414
</div>
1515
<div class="panel-body">
16+
<div class="row" *ngIf="displayPkId">
17+
<div class="col-sm-12 col-md-12">
18+
<div class="col-sm-1 col-md-1 textRight">
19+
pk_id
20+
</div>
21+
<div class="col-sm-11 col-md-11">
22+
: {{authorJsonObj.pk_id}}
23+
</div>
24+
</div>
25+
</div>
1626
<!-- 氏名 start -->
1727
<div class="row">
1828
<div class="col-sm-12 col-md-12">
@@ -116,7 +126,7 @@ <h5>
116126
</select>
117127
</div>
118128
<div class="col-sm-5 col-md-5">
119-
<input [disabled]="authorIdData.idType == 1" type="text" class="form-control" placeholder="" [(ngModel)]="authorIdData.authorId">
129+
<input type="text" class="form-control" placeholder="" [(ngModel)]="authorIdData.authorId">
120130
</div>
121131
<div class="col-sm-2 col-md-2">
122132
<div class="">
@@ -377,7 +387,64 @@ <h5>
377387
</div>
378388
</div>
379389
</div>
380-
<!-- 所属機関名 end -->
390+
<!-- 所属機関名 end -->
391+
<!-- 所属機関所属期間 start -->
392+
<div class="row">
393+
394+
<div class="col-sm-12 col-md-12">
395+
<div class="col-sm-1 col-md-1 textRight">
396+
<!-- 所属機関所属期間 -->
397+
{{langJson.Author_Affiliation_Period[1]}}
398+
</div>
399+
<div class="col-sm-11 col-md-11">
400+
<!-- for start -->
401+
<ng-container *ngFor="let affiliationPeriodData of affiliationData.affiliationPeriodInfo;let affiliationPeriodIndex=index">
402+
<div class="">
403+
<div class="col-sm-12 col-md-12 divBottom">
404+
<div class="col-sm-2 col-md-2">
405+
</div>
406+
<div class="col-sm-1 col-md-1">
407+
</div>
408+
<div class="col-sm-1 col-md-1 textRight">
409+
{{langJson.Author_Affiliation_Period_Start[1]}}
410+
</div>
411+
<div class="ccol-sm-2 col-md-2">
412+
<input type="text" class="form-control" placeholder={{placeholderForDate}} [(ngModel)]="affiliationPeriodData.periodStart">
413+
</div>
414+
<div class="col-sm-1 col-md-1 textRight">
415+
<!-- 所属機関所属期間 -->
416+
{{langJson.Author_Affiliation_Period_End[1]}}
417+
</div>
418+
<div class="col-sm-2 col-md-2">
419+
<input type="text" class="form-control" placeholder={{placeholderForDate}} [(ngModel)]="affiliationPeriodData.periodEnd">
420+
</div>
421+
<div class="col-sm-2 col-md-2">
422+
</div>
423+
<div class="col-sm-1 col-md-1">
424+
<div>
425+
<button type="button" class="close delButton" (click)="delAffiliationPeriodData(affiliationIndex, affiliationPeriodIndex)">
426+
<span class="glyphicon glyphicon-remove"></span>
427+
</button>
428+
</div>
429+
</div>
430+
</div>
431+
</div>
432+
<p></p>
433+
</ng-container>
434+
<!-- 第二行目 -->
435+
<div class="row ">
436+
<div class="col-sm-11 col-md-11 textRight">
437+
<button type="button" class="btn btn-link" (click)="addAffiliationPeriod(affiliationIndex)">+&nbsp;
438+
<!-- 所属機関所属期間を追加 -->
439+
{{langJson.Author_Add_Affiliation_Period[1]}}
440+
</button>
441+
</div>
442+
</div>
443+
<!-- 第二行目 end-->
444+
</div>
445+
</div>
446+
</div>
447+
<!-- 所属機関名 end -->
381448
</div>
382449
</div>
383450
</div>
@@ -421,6 +488,10 @@ <h5>
421488
<span class="glyphicon glyphicon-download-alt"></span>
422489
{{langJson.Author_Button_Save[1]}}
423490
</button>
491+
<label *ngIf="forceChangeCheck">
492+
<input type="checkbox" [(ngModel)]="forceChangeFlag">
493+
{{langJson.Author_Force_Change_Flag[1]}}
494+
</label>
424495
</div>
425496
</div>
426497
<!-- ボタン end -->

app-author-add/src/app/app.component.ts

Lines changed: 91 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, OnInit, Input } from '@angular/core';
2+
import { a } from '@angular/core/src/render3';
23
import { Http, RequestOptions, Headers } from '@angular/http';
34
import 'rxjs/add/operator/toPromise';
45
declare var $: any;
@@ -26,6 +27,10 @@ export class AppComponent implements OnInit {
2627
Author_Add_Identifier: [],
2728
Author_Affiliation_Name: [],
2829
Author_Add_Affiliation_Name: [],
30+
Author_Affiliation_Period:[],
31+
Author_Affiliation_Period_Start:[],
32+
Author_Affiliation_Period_End:[],
33+
Author_Add_Affiliation_Period:[],
2934
Author_Affiliation: [],
3035
Author_Add_Affiliation: [],
3136
Author_Button_Delete: [],
@@ -34,9 +39,13 @@ export class AppComponent implements OnInit {
3439
Author_familyNmAndNm: [],
3540
Author_fullNm: [],
3641
Author_placeholder_authorId: [],
37-
Author_Confirm_Msg: []
42+
Author_Confirm_Msg: [],
43+
Author_Force_Change_Flag: []
3844
};
3945
public deleteBtn :boolean = false;
46+
public forceChangeCheck: boolean = false;
47+
public forceChangeFlag: boolean = false;
48+
public displayPkId: boolean = false;
4049
//set data of page by json
4150
public authorJsonObj: any = {
4251
id: "",
@@ -53,7 +62,7 @@ export class AppComponent implements OnInit {
5362
],
5463
authorIdInfo: [
5564
{
56-
idType: "2",
65+
idType: "1",
5766
authorId: "",
5867
authorIdShowFlg: "true"
5968
}
@@ -76,6 +85,12 @@ export class AppComponent implements OnInit {
7685
affiliationNameLang: "ja",
7786
affiliationNameShowFlg: "true"
7887
}
88+
],
89+
affiliationPeriodInfo: [
90+
{
91+
periodStart: null,
92+
periodEnd: null
93+
}
7994
]
8095
}
8196
]
@@ -132,6 +147,7 @@ export class AppComponent implements OnInit {
132147
}
133148
];
134149

150+
public placeholderForDate: string ="yyyy-mm-dd";
135151

136152
constructor(private http: Http,
137153
) { }
@@ -146,12 +162,16 @@ export class AppComponent implements OnInit {
146162
}
147163

148164
/**
149-
*
165+
* 初期値の取得
166+
*
150167
*/
151168
getAuthorData() {
152169
let urlStr = window.location.href;
170+
// editの場合
153171
if (urlStr.indexOf("edit")!= -1) {
154172
this.deleteBtn = true;
173+
this.forceChangeCheck = true;
174+
this.displayPkId = true;
155175
let paramJson = { Id: "" }
156176
paramJson.Id = urlStr.substring(urlStr.indexOf("=")).replace("=", "");
157177
this.getDataOfAuthor(paramJson).then(
@@ -160,7 +180,14 @@ export class AppComponent implements OnInit {
160180
console.log(res)
161181
}
162182
).catch()
183+
// addの場合
163184
}else{
185+
// 初期値でweko_idの最大値+1を設定する。
186+
this.getDataOfMaxWekoId().then(
187+
res => {
188+
this.authorJsonObj.authorIdInfo[0].authorId = String(res.max_author_id + 1);
189+
}
190+
).catch()
164191
this.deleteBtn = false;
165192
}
166193
}
@@ -316,6 +343,15 @@ export class AppComponent implements OnInit {
316343
this.authorJsonObj.affiliationInfo[affiliationIndex].affiliationNameInfo.splice(affiliationNameIndex, 1)
317344
}
318345
}
346+
delAffiliationPeriodData(affiliationIndex: string | number, affiliationPeriodIndex: any) {
347+
//全部削除する場合
348+
if (this.authorJsonObj.affiliationInfo[affiliationIndex].affiliationPeriodInfo.length == 1) {
349+
let subAffiliationPeriodInfoObj = this.returnSubAffiliationPeriodInfoObj();
350+
this.authorJsonObj.affiliationInfo[affiliationIndex].affiliationPeriodInfo.splice(affiliationPeriodIndex, 1, subAffiliationPeriodInfoObj);
351+
} else {
352+
this.authorJsonObj.affiliationInfo[affiliationIndex].affiliationPeriodInfo.splice(affiliationPeriodIndex, 1)
353+
}
354+
}
319355
/**
320356
* affiliationを削除する
321357
* @@param 削除する位置情報
@@ -380,6 +416,21 @@ export class AppComponent implements OnInit {
380416
//行目を追加
381417
this.authorJsonObj.affiliationInfo[affiliationIndex].affiliationNameInfo.push(subAffiliationNameInfoObj);
382418
}
419+
/**
420+
* 所属期間情報を追加する
421+
* @@param 追加する位置情報
422+
*/
423+
addAffiliationPeriod(affiliationIndex: any) {
424+
//子対象を取得する
425+
let subAffiliationPeriodInfoObj = this.returnSubAffiliationPeriodInfoObj();
426+
if (this.authorJsonObj.affiliationInfo[affiliationIndex].affiliationPeriodInfo === undefined) {
427+
this.authorJsonObj.affiliationInfo[affiliationIndex].affiliationPeriodInfo = [];
428+
}
429+
//行目を追加
430+
this.authorJsonObj.affiliationInfo[affiliationIndex].affiliationPeriodInfo.push(subAffiliationPeriodInfoObj);
431+
}
432+
433+
383434
/**
384435
* 所属情報を追加する
385436
*/
@@ -490,20 +541,36 @@ export class AppComponent implements OnInit {
490541
}
491542
return subAffiliationNameInfoObj;
492543
}
544+
/**
545+
* affiliationPeriod情報を返す
546+
*/
547+
returnSubAffiliationPeriodInfoObj(): any {
548+
//所属期間情報
549+
let subAffiliationPeriodInfoObj = {
550+
periodStart: null,
551+
periodEnd: null
552+
}
553+
return subAffiliationPeriodInfoObj;
554+
}
493555
/**
494556
* affiliation情報を返す
495557
*/
496558
returnSubAffiliationInfoObj(): any {
497559
//所属情報
498560
let subAffiliationInfoObj = {
499561
"identifierInfo": [],
500-
"affiliationNameInfo": []
562+
"affiliationNameInfo": [],
563+
"affiliationPeriodInfo": []
501564
}
502565
let subIdentifierInfoObj = this.returnSubIdentifierInfoObj();
503566
subAffiliationInfoObj.identifierInfo.push(subIdentifierInfoObj);
504567

505568
let subAffiliationNameInfoObj = this.returnSubAffiliationNameInfoObj();
506569
subAffiliationInfoObj.affiliationNameInfo.push(subAffiliationNameInfoObj);
570+
571+
let subAffiliationPeriodInfoObj = this.returnSubAffiliationPeriodInfoObj();
572+
subAffiliationInfoObj.affiliationPeriodInfo.push(subAffiliationPeriodInfoObj);
573+
507574
return subAffiliationInfoObj;
508575
}
509576

@@ -547,15 +614,15 @@ export class AppComponent implements OnInit {
547614
var urlArr = window.location.href.split('/');
548615
window.location.href = urlArr[0] + "//" + urlArr[2] + "/admin/authors/";
549616
}).catch(res => {
550-
alert(res.msg);
617+
alert(JSON.parse(res._body).msg);
551618
})
552619
}else{
553620
this.postPageDataJson(dbJson).then(res => {
554621
// alert(res.msg); // Flash message one admin page instead
555622
var urlArr = window.location.href.split('/');
556623
window.location.href = urlArr[0] + "//" + urlArr[2] + "/admin/authors/";
557624
}).catch(res => {
558-
alert(res.msg);
625+
alert(JSON.parse(res._body).msg);
559626
})
560627
}
561628
}
@@ -663,7 +730,9 @@ export class AppComponent implements OnInit {
663730
var urlArr = window.location.href.split('/');
664731
const url = urlArr[0] + "//" + urlArr[2] + "/api/authors/edit"
665732
return this.http
666-
.post(url, authorJsonObj)
733+
.post(url,
734+
{author: authorJsonObj,
735+
forceChangeFlag: this.forceChangeFlag})
667736
.toPromise()
668737
.then(response => response.json() as any)
669738
.catch(this.handleError);
@@ -693,7 +762,7 @@ export class AppComponent implements OnInit {
693762
.catch(this.handleError);
694763
}
695764
/**
696-
*
765+
* call api (get author data by id)
697766
*/
698767
getDataOfAuthor(esid: any) {
699768
var urlArr = window.location.href.split('/');
@@ -704,6 +773,20 @@ export class AppComponent implements OnInit {
704773
.then(response => response.json() as any)
705774
.catch(this.handleError);
706775
}
776+
777+
/**
778+
* call api (get max weko id)
779+
*/
780+
getDataOfMaxWekoId(){
781+
var urlArr = window.location.href.split('/');
782+
const url = urlArr[0] + "//" + urlArr[2] + "/api/authors/get_max_weko_id"
783+
return this.http
784+
.get(url)
785+
.toPromise()
786+
.then(response => response.json() as any)
787+
.catch(this.handleError);
788+
}
789+
707790
/**
708791
* call api (get author prefix prefix)
709792
*/

app-author-search/src/app/app.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ export class AppComponent implements OnInit {
384384
if(this.searchJson.item_cnt.aggregations.item_count.buckets.length != 0){
385385
for(let cntData of this.searchJson.item_cnt.aggregations.item_count.buckets){
386386
let authorIdInfo = data._source.authorIdInfo;
387-
if (Array.isArray(authorIdInfo) && authorIdInfo.length && cntData.key == authorIdInfo[0].authorId) {
387+
let pkId = data._source.pk_id;
388+
if (cntData.key == pkId) {
388389
subData.itemCnt = cntData.doc_count;
389390
break;
390391
}

0 commit comments

Comments
 (0)