외교부 틀 작성중. 재야의 외교 메시지는 항상 보이도록

This commit is contained in:
2019-01-26 03:31:04 +09:00
parent 9aff52eaad
commit e6b2107fa9
7 changed files with 150 additions and 23 deletions
+58
View File
@@ -0,0 +1,58 @@
#newLetter {
width:1000px;
margin: 10px auto;
}
#newLetter th{
width:16ch;
}
#newLetter textarea{
width:100%;
min-height:6em;
color:white;
background-color:transparent;
border:none;
}
.letterFrame{
width:1000px;
margin: 10px auto;
}
.letterFrame th{
width:16ch;
}
.letterHeader{
position: relative;
font-size:200%;
}
.letterDate{
position: absolute;
right:1ch;
bottom:0.2em;
font-size:50%;
}
.letterBrief, .letterDetail{
text-align: left;
}
.letterSignerPlate{
text-align:center;
}
.letterSrc, .letterDest{
display:inline-block;
margin: 0 10px;
border: 1px solid gray;
width:110px;
text-align:center;
}
.signerNation, .signerName{
border-top: 1px solid gray;
}
+7 -1
View File
@@ -64,6 +64,12 @@ if($isAgree){
'aux'=>Json::encode($aux)
], 'no=%i', $letterNo);
//TODO: 외교 서신에 대한 메시지를 양국에 발송해야함
if($letter['prev_no'] !== null){
$db->update('ng_diplomacy', [
'state'=>'replaced',
], 'no=%i', $letter['prev_no']);
}
}
else{
$aux['reason'] = [
@@ -74,7 +80,7 @@ else{
$db->update('ng_diplomacy', [
'state'=>'cancelled',
'aux'=>Json::encode($aux)
]);
], 'no=%i', $letterNo);
//TODO: 외교 서신에 대한 메시지를 양국에 발송해야함
}
+28 -10
View File
@@ -65,18 +65,10 @@ if ($permission < 4) {
$srcNationNo = $me['nation'];
$nations = $db->query('SELECT nation, name, color FROM nation WHERE nation IN (%i, %i)', $srcNationNo, $destNationNo);
if(count($nations) != 2){
Json::die([
'result'=>false,
'reason'=>'올바르지 않은 국가입니다.'
]);
}
if($prevNo !== null){
//state는 체크하지 않는걸로 하자. 파기한 것을 재 송신하는 경우도 있을 수 있음.
$prevLetter = $db->queryFirstRow(
'SELECT no, state, aux FROM ng_diplomacy WHERE no = %i AND src_nation_id IN (%i, %i) AND dest_nation_id IN (%i, %i)',
'SELECT no, src_nation_id, dest_nation_id, state, aux FROM ng_diplomacy WHERE no = %i AND src_nation_id IN (%i, %i) AND dest_nation_id IN (%i, %i)',
$prevNo,
$srcNationNo, $destNationNo,
$srcNationNo, $destNationNo
@@ -89,6 +81,24 @@ if($prevNo !== null){
]);
}
//새로 나온 문서가 있는지 확인하자
$newerLetter = $db->queryFirstField(
'SELECT count(no) FROM ng_diplomacy WHERE prev_no = %i AND state != \'cancelled\'', $prevNo
);
if($newerLetter){
Json::die([
'result'=>false,
'reason'=>'해당 문서에 대한 새로운 문서가 이미 있습니다.'
]);
}
if($prevLetter['src_nation_id'] != $srcNationNo){
$destNationNo = $prevLetter['src_nation_id'];
}
else{
$destNationNo = $prevLetter['dest_nation_id'];
}
if($prevLetter['state'] == 'proposed'){
$prevAux = Json::decode($prevLetter['aux']);
$prevAux['reason'] = [
@@ -97,12 +107,20 @@ if($prevNo !== null){
'reason'=>'new_letter'
];
$db->update('ng_diplomacy', [
'state'=>'cancelled',
'state'=>'replaced',
'aux'=>Json::encode($prevAux)
], 'no=%i', $prevNo);
}
}
$nations = $db->query('SELECT nation, name, color FROM nation WHERE nation IN (%i, %i)', $srcNationNo, $destNationNo);
if(count($nations) != 2){
Json::die([
'result'=>false,
'reason'=>'올바르지 않은 국가입니다.'
]);
}
if($nations[0]['nation'] == $me['nation']){
//index 순서에 따라 또 모름.
$srcNation = $nations[0];
+1 -1
View File
@@ -101,7 +101,7 @@ $result['diplomacy']= array_map(function(Message $msg)use (&$nextSequence, &$min
$lastType = 'diplomacy';
}
$values = $msg->toArray();
if($permission < 3){
if($msg->dest->nationID != 0 && $permission < 3){
$values['text'] = '(외교 문서입니다)';//TODO: 외교서신이라 읽을 수 없음을 보여줘야함
}
return $values;
+6 -1
View File
@@ -135,6 +135,10 @@ function loadLetters(){
$(function(){
$('textarea.autosize').on('keydown keyup', function(){
$(this).height(1).height( $(this).prop('scrollHeight')+12 );
})
$('#submitLetter').click(submitLetter);
$('.respondAgree').click(function(){
return repondLetter(true);
@@ -143,10 +147,11 @@ $('.respondDisagree').click(function(){
return repondLetter(false);
});
/*
loadLetters()
.then(drawLetters, errUnknown)
.fail(function(reason){
alert(reason);
});
});*/
});
+1 -1
View File
@@ -565,7 +565,7 @@ CREATE TABLE `ng_diplomacy` (
`src_nation_id` INT(11) NOT NULL,
`dest_nation_id` INT(11) NOT NULL,
`prev_no` INT(11) NULL DEFAULT NULL,
`state` ENUM('proposed','activated','cancelled') NOT NULL DEFAULT 'proposed',
`state` ENUM('proposed','activated','cancelled','replaced') NOT NULL DEFAULT 'proposed',
`text_brief` TEXT NOT NULL,
`text_detail` TEXT NOT NULL,
`date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+49 -9
View File
@@ -50,21 +50,61 @@ var permissionLevel = <?=$permission?>; //
<?=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
<!--<?=WebUtil::printJS('../e_lib/tui.editor/tui-editor-Editor-all.min.js')?>-->
<?=WebUtil::printJS('js/common.js')?>
<?=WebUtil::printJS('js/board.js')?>
<?=WebUtil::printJS('js/diplomacy.js')?>
</head>
<body>
<template id='diplomacyTemplate'>
<div class='diplomacyFrame'>
<div><span class='articleTitle'></span></div>
<div class='authorPlate'><span class='authorIcon'></span><span class='authorName'><span><span class='date'></span></div>
<div class='boardArticle'>
<table id='newLetter' class='bg0' style='display:none;'>
<thead>
<tr><td colspan='2' class='newLetterHeader'>새 외교문서 작성</td>
</thead>
<tbody>
<tr><th class='bg1'>이전 문서</th><td><select id='inputPrevNo'></select></td></tr>
<tr><th class='bg1'>대상 국가</th><td><select id='inputDestNation'></select></td></tr>
<tr><th class='bg1'>내용(공개)</th><td><textarea id='inputBrief' class='autosize'></textarea></td></tr>
<tr><th class='bg1'>내용(비밀)</th><td><textarea id='inputDetail' class='autosize'></textarea></td></tr>
</tbody>
<tfoot>
<tr class='letterActionPlate'><th class='bg1'>동작</th><td>
<button type='button' id='btnSend'>전송</button>
</td></tr>
</tfoot>
</table>
<!-- 설계미스. template와 shadowdom으로 변경 -->
<div id='letterTemplate' style='display:none;'>
<table class='letterFrame bg0'>
<thead>
<tr><td colspan='2' class='letterHeader'>홍길동<span class='letterNationName'></span>국과의 외교 문서<span class='letterDate'>2099-12-31 23:59:59</span></td>
</thead>
<tbody>
<tr><th class='bg1'>문서 번호</th><td>#<span class='letterNo'></span></td></tr>
<tr><th class='bg1'>이전 문서</th><td>#<span class='letterPrevNo'></span></td></tr>
<tr><th class='bg1'>상태</th><td><span class='letterStatus'></span></td></tr>
<tr><th class='bg1'>내용(공개)</th><td><div class='letterBrief'></div></td></tr>
<tr><th class='bg1'>내용(비밀)</th><td><div class='letterDetail'></div></td></tr>
</tbody>
<tfoot>
<tr><th class='bg1'>서명인</th><td class='letterSignerPlate'>
<div class='letterSrc'>
<div class="signerImg"><img class='generalIcon' width='64px' height='64px'></div>
<div class="signerNation">&nbsp;</div>
<div class="signerName">&nbsp;</div>
</div><div class='letterDest'>
<div class="signerImg"><img class='generalIcon' width='64px' height='64px'></div>
<div class="signerNation">&nbsp;</div>
<div class="signerName">&nbsp;</div>
</div>
</td></tr>
<tr class='letterActionPlate'><th class='bg1'>동작</th><td>
<button type='button' class='btnAgree'>승락</button>
<button type='button' class='btnDisagree'>거절</button>
<button type='button' class='btnRenew'>갱신</button>
</td></tr>
</tfoot>
</table>
</div>
</div>
</div>
</template>
<div style='width=1000px;' class='tb_layout bg0'>
<?=backButton()?><br>