changed project name

This commit is contained in:
2025-02-07 18:57:23 +09:00
parent dec0e73dbb
commit 2023ca601f
14 changed files with 5487 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
<script type="module" crossorigin src="/src/js/config.js"></script>
<section class="settings">
<div id="app"></div>
</section>

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,130 @@
/* 辅助类 */
.flex-row {
display: flex;
}
.hidden {
visibility: hidden;
}
.border {
border: 1px solid #e3e7e8;
}
/* config 页面 */
#app {
width: 60vw;
min-width: 940px;
}
/* 最上面的说明 */
.settings-heading {
padding: 1em 0;
}
/* label 样式 */
.kintoneplugin-label {
padding-left: 20px;
line-height: 40px;
}
/* laebl input 单行的情况 */
.flex-row .kintoneplugin-label {
margin: 0;
width: 8.5em;
}
/* 遮罩 */
#main-area {
position: relative;
}
#main-area .kuc-spinner-1-18-0__mask {
position: absolute;
background-color: white;
}
#main-area .kuc-spinner-1-18-0__spinner {
position: absolute;
}
#main-area .kuc-spinner-1-18-0__spinner__loader {
fill: #3498db;
}
/* 表格内容垂直居中 */
.table-area {
margin: 0;
align-items: center;
}
/* 整体边框相关样式 */
.header-row {
padding: 24px 0;
margin: 0;
border-bottom: none;
}
.table-main-area {
flex: 1;
border-right: 1px solid #e3e7e8;
padding-top: 24px;
}
.footer-row {
padding: 24px 0;
margin-bottom: 32px;
text-align: right;
border-top: none;
}
/* 底部按钮空间 */
.save-btn {
margin-left: 16px;
margin-right: 24px;
}
/* 输入框宽度 */
.kuc-text-input {
--kuc-text-input-width: max(15vw, 200px);
--kuc-dropdown-toggle-width: max(15vw, 200px);
--kuc-combobox-toggle-width: max(15vw, 200px);
}
/* 统一 kintone +/- 按钮样式 */
.kuc-action-button {
width: 24px;
height: 24px;
background: transparent;
border: 1px solid transparent;
padding: 2px;
cursor: pointer;
margin: 0 4px;
}
.kuc-action-button.remove {
margin-right: 8px;
}
.kuc-action-button.add {
margin-left: 8px;
}
.kuc-action-button:focus {
border: 1px solid #3498db;
outline: none;
}
.kuc-action-button.remove:hover path {
fill: #e74c3c;
}
/* 覆盖表格样式 */
.plugin-kuc-table td {
border-left-color: rgba(0, 0, 0, 0);
border-right-color: rgba(0, 0, 0, 0);
vertical-align: middle;
}
.plugin-kuc-table tr td:nth-last-child(2) {
border-right-color: #e3e7e8;
}
.plugin-kuc-table tr td:first-child {
border-left-color: #e3e7e8;
}
.plugin-kuc-table .kuc-table-1-18-0__table__body__row__action {
height: 55px;
align-items: center;
}
/* 絞り込み条件选择相关样式 */
.row-connector-area {
margin: 0 1em;
}

View File

@@ -0,0 +1,10 @@
.plugin-space-heading {
font-size: 1.5rem;
margin: 0.8rem;
}
.plugin-space-message {
display: inline-block;
font-size: 1.2em;
margin: 0.8rem;
margin-top: 0;
}

View File

@@ -0,0 +1,11 @@
.plugin-space-message {
display: inline-block;
font-size: 1.2em;
margin: 0.8rem;
margin-top: 0;
}
.plugin-space-heading {
font-size: 1.5rem;
margin: 0.8rem;
}

View File

@@ -0,0 +1,4 @@
<script type="module" crossorigin src="/src/js/config.js"></script>
<section class="settings">
<div id="app"></div>
</section>

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 B

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
var f=Object.defineProperty;var E=(c,e,t)=>e in c?f(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t;var l=(c,e,t)=>E(c,typeof e!="symbol"?e+"":e,t);new KintoneRestAPIClient;const h=["RECORD_NUMBER","CREATOR","CREATED_TIME","MODIFIER","UPDATED_TIME","CATEGORY","STATUS","STATUS_ASSIGNEE","SINGLE_LINE_TEXT","NUMBER","CALC","MULTI_LINE_TEXT","RICH_TEXT","LINK","CHECK_BOX","RADIO_BUTTON","DROP_DOWN","MULTI_SELECT","FILE","DATE","TIME","DATETIME","USER_SELECT","ORGANIZATION_SELECT","GROUP_SELECT","GROUP","REFERENCE_TABLE","SUBTABLE"];h.reduce((c,e)=>(c[e]=e,c),{});function C(c){return e=>(e==null?void 0:e.type)===c}const u=Object.fromEntries(h.map(c=>[c,C(c)]));class T{constructor(e,t){l(this,"config");l(this,"currentApp");l(this,"handleButtonClick",async()=>{const e=this.showSpinner();try{console.log("データ収集開始..."),await this.execDataFectch(),e.close(),location.reload()}catch(t){e.close();const r=`データ収集中処理中例外発生しました。${t instanceof Error?`
詳細:`+t.message:""}`;console.error(r,t),window.alert(r)}});l(this,"execDataFectch",async()=>{const e=this.config.joinTables[0];let n=(await this.fetchDataFromApp(e)).map(i=>{const o={};return e.fieldsMapping.forEach(s=>{o[this.fieldCode(s.rightField)]=i[this.fieldCode(s.leftField)]}),o});const r=this.config.joinTables.filter((i,o)=>o>0);for(const i of r){const o=await this.fetchDataFromApp(i);n=this.leftJoin(n,o,i)}await this.deleteCurrentRecords(),await this.saveDataToCurrentApp(n)});l(this,"fetchDataFromApp",async e=>{const t=this.getWhereCondition(e.whereConditions),n=e.fieldsMapping.map(s=>this.fieldCode(s.leftField));e.table&&n.push(e.table),e.onConditions.map(s=>this.fieldCode(s.leftField)).forEach(s=>{n.includes(s)||n.push(s)});const o=await new KintoneRestAPIClient().record.getAllRecords({app:e.app,fields:n,condition:t});return this.convertToFlatDatas(o,e.table)});this.config=e,this.currentApp=t}init(){this.addButtonToView()}addButtonToView(){const e=kintone.app.getHeaderMenuSpaceElement();if(!e)throw new Error("このページではヘッダー要素が利用できません。");if(document.getElementById("btn-data-fetch"))return;const t=Kucs["1.18.0"],n=new t.Button({text:this.config.buttonName,type:"submit",id:"btn-data-fetch"});n.addEventListener("click",()=>this.handleButtonClick()),e.appendChild(n)}showSpinner(){const e=Kucs["1.18.0"],t=new e.Spinner({text:"データ収集中",container:document.body});return t.open(),t}getWhereCondition(e){return e.filter(r=>this.fieldCode(r.field)!=="").map(r=>{let i=r.condition;"subField"in r.field&&r.field.subField&&(i=this.mapConditionForSubField(r.condition));const o=this.getConditionValue(r.field,i,r.data);return`${this.fieldCode(r.field)} ${i} ${o}`}).join(" and ")}mapConditionForSubField(e){switch(e){case"=":return"in";case"!=":return"not in";default:return e}}getConditionValue(e,t,n){return n?u.NUMBER(e)||u.RECORD_NUMBER(e)?n:u.DATE(e)?/^\d{4}-\d{2}-\d{2}$/.test(n)||n.match(/^\w+\(.*\)$/)?`"${n}"`:`"${new Date(n).toISOString().split("T")[0]}"`:u.DATETIME(e)||u.CREATED_TIME(e)||u.UPDATED_TIME(e)?n.match(/^\w+\(.*\)$/)?`"${n}"`:`"${new Date(n).toISOString()}"`:t==="in"||t==="not in"?n.includes(",")?`(${n.split(",").map(i=>`"${i.trim()}"`).join(",")})`:`("${n}")`:`"${n}"`:""}fieldCode(e){return e?typeof e=="string"&&e?e:typeof e=="object"&&"code"in e?e.code:"":""}convertToFlatDatas(e,t){if(!t)return e;const n=[];return e.forEach(r=>{var i;if(((i=r[t])==null?void 0:i.type)==="SUBTABLE"&&r[t].value.length>0)r[t].value.forEach(o=>{const s={...r};Object.entries(o.value).forEach(([d,a])=>{s[d]={value:a.value,type:a.type}}),delete s[t],n.push(s)});else{const o={...r};delete o[t],n.push(o)}}),n}leftJoin(e,t,n){const r=[];return e.forEach(i=>{const o=t.filter(s=>n.onConditions.every(d=>{var a,p;return((a=i[this.fieldCode(d.rightField)])==null?void 0:a.value)===((p=s[this.fieldCode(d.leftField)])==null?void 0:p.value)}));o?o.forEach(s=>{const d={...i};n.fieldsMapping.forEach(a=>{d[this.fieldCode(a.rightField)]=s[this.fieldCode(a.leftField)]}),r.push(d)}):r.push(i)}),r}async deleteCurrentRecords(){const e=new KintoneRestAPIClient,n=(await e.record.getAllRecords({app:this.currentApp,fields:["$id"]})).map(r=>({id:r.$id.value}));await e.record.deleteAllRecords({app:this.currentApp,records:n}),e.record.addAllRecords}async saveDataToCurrentApp(e){try{const n=await new KintoneRestAPIClient().record.addAllRecords({app:this.currentApp,records:this.convertForUpdate(e)})}catch(t){throw console.error("データ作成時エラーが発生しました:",t),t}}convertForUpdate(e){return e.map(t=>Object.fromEntries(Object.entries(t).map(([n,{value:r}])=>[n,{value:r}])))}}(function(c){kintone.events.on("app.record.index.show",t=>{var n;try{const r=kintone.plugin.app.getConfig(c),i=e(r),o=(n=kintone.app.getId())==null?void 0:n.toString();if(!o)return;new T(i,o).init()}catch(r){const o=`データ収集中処理中例外発生しました。${r instanceof Error?`
詳細:`+r.message:""}`;t.error=o}return t});function e(t){return{buttonName:t.buttonName,joinTables:JSON.parse(t.joinTables)}}})(kintone.$PLUGIN_ID);

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
var f=Object.defineProperty;var E=(c,e,t)=>e in c?f(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t;var l=(c,e,t)=>E(c,typeof e!="symbol"?e+"":e,t);new KintoneRestAPIClient;const h=["RECORD_NUMBER","CREATOR","CREATED_TIME","MODIFIER","UPDATED_TIME","CATEGORY","STATUS","STATUS_ASSIGNEE","SINGLE_LINE_TEXT","NUMBER","CALC","MULTI_LINE_TEXT","RICH_TEXT","LINK","CHECK_BOX","RADIO_BUTTON","DROP_DOWN","MULTI_SELECT","FILE","DATE","TIME","DATETIME","USER_SELECT","ORGANIZATION_SELECT","GROUP_SELECT","GROUP","REFERENCE_TABLE","SUBTABLE"];h.reduce((c,e)=>(c[e]=e,c),{});function C(c){return e=>(e==null?void 0:e.type)===c}const p=Object.fromEntries(h.map(c=>[c,C(c)]));class T{constructor(e,t){l(this,"config");l(this,"currentApp");l(this,"handleButtonClick",async()=>{const e=this.showSpinner();try{console.log("データ収集開始..."),await this.execDataFectch(),e.close(),location.reload()}catch(t){e.close();const r=`データ収集中処理中例外発生しました。${t instanceof Error?`
詳細:`+t.message:""}`;console.error(r,t),window.alert(r)}});l(this,"execDataFectch",async()=>{const e=this.config.joinTables[0];let n=(await this.fetchDataFromApp(e)).map(i=>{const o={};return e.fieldsMapping.forEach(s=>{o[this.fieldCode(s.rightField)]=i[this.fieldCode(s.leftField)]}),o});const r=this.config.joinTables.filter((i,o)=>o>0);for(const i of r){const o=await this.fetchDataFromApp(i);n=this.leftJoin(n,o,i)}await this.deleteCurrentRecords(),await this.saveDataToCurrentApp(n)});l(this,"fetchDataFromApp",async e=>{const t=this.getWhereCondition(e.whereConditions),n=e.fieldsMapping.map(s=>this.fieldCode(s.leftField));e.table&&n.push(e.table),e.onConditions.map(s=>this.fieldCode(s.leftField)).forEach(s=>{n.includes(s)||n.push(s)});const o=await new KintoneRestAPIClient().record.getAllRecords({app:e.app,fields:n,condition:t});return this.convertToFlatDatas(o,e.table)});this.config=e,this.currentApp=t}init(){this.addButtonToView()}addButtonToView(){const e=kintone.mobile.app.getHeaderSpaceElement();if(!e)throw new Error("このページではヘッダー要素が利用できません。");if(document.getElementById("btn-data-fetch"))return;const t=Kucs["1.18.0"],n=new t.Button({text:this.config.buttonName,type:"submit",id:"btn-data-fetch"});n.addEventListener("click",()=>this.handleButtonClick()),e.appendChild(n)}showSpinner(){const e=Kucs["1.18.0"],t=new e.Spinner({text:"データ収集中",container:document.body});return t.open(),t}getWhereCondition(e){return e.filter(r=>this.fieldCode(r.field)!=="").map(r=>{let i=r.condition;"subField"in r.field&&r.field.subField&&(i=this.mapConditionForSubField(r.condition));const o=this.getConditionValue(r.field,i,r.data);return`${this.fieldCode(r.field)} ${i} ${o}`}).join(" and ")}mapConditionForSubField(e){switch(e){case"=":return"in";case"!=":return"not in";default:return e}}getConditionValue(e,t,n){return n?p.NUMBER(e)||p.RECORD_NUMBER(e)?n:p.DATE(e)?/^\d{4}-\d{2}-\d{2}$/.test(n)||n.match(/^\w+\(.*\)$/)?`"${n}"`:`"${new Date(n).toISOString().split("T")[0]}"`:p.DATETIME(e)||p.CREATED_TIME(e)||p.UPDATED_TIME(e)?n.match(/^\w+\(.*\)$/)?`"${n}"`:`"${new Date(n).toISOString()}"`:t==="in"||t==="not in"?n.includes(",")?`(${n.split(",").map(i=>`"${i.trim()}"`).join(",")})`:`("${n}")`:`"${n}"`:""}fieldCode(e){return e?typeof e=="string"&&e?e:typeof e=="object"&&"code"in e?e.code:"":""}convertToFlatDatas(e,t){if(!t)return e;const n=[];return e.forEach(r=>{var i;if(((i=r[t])==null?void 0:i.type)==="SUBTABLE"&&r[t].value.length>0)r[t].value.forEach(o=>{const s={...r};Object.entries(o.value).forEach(([d,a])=>{s[d]={value:a.value,type:a.type}}),delete s[t],n.push(s)});else{const o={...r};delete o[t],n.push(o)}}),n}leftJoin(e,t,n){const r=[];return e.forEach(i=>{const o=t.filter(s=>n.onConditions.every(d=>{var a,u;return((a=i[this.fieldCode(d.rightField)])==null?void 0:a.value)===((u=s[this.fieldCode(d.leftField)])==null?void 0:u.value)}));o?o.forEach(s=>{const d={...i};n.fieldsMapping.forEach(a=>{d[this.fieldCode(a.rightField)]=s[this.fieldCode(a.leftField)]}),r.push(d)}):r.push(i)}),r}async deleteCurrentRecords(){const e=new KintoneRestAPIClient,n=(await e.record.getAllRecords({app:this.currentApp,fields:["$id"]})).map(r=>({id:r.$id.value}));await e.record.deleteAllRecords({app:this.currentApp,records:n}),e.record.addAllRecords}async saveDataToCurrentApp(e){try{const n=await new KintoneRestAPIClient().record.addAllRecords({app:this.currentApp,records:this.convertForUpdate(e)})}catch(t){throw console.error("データ作成時エラーが発生しました:",t),t}}convertForUpdate(e){return e.map(t=>Object.fromEntries(Object.entries(t).map(([n,{value:r}])=>[n,{value:r}])))}}(function(c){kintone.events.on("mobile.app.record.index.show",t=>{var n;try{const r=kintone.plugin.app.getConfig(c),i=e(r),o=(n=kintone.mobile.app.getId())==null?void 0:n.toString();if(!o)return;new T(i,o).init()}catch(r){const o=`データ収集中処理中例外発生しました。${r instanceof Error?`
詳細:`+r.message:""}`;t.error=o}return t});function e(t){return{buttonName:t.buttonName,joinTables:JSON.parse(t.joinTables)}}})(kintone.$PLUGIN_ID);

View File

@@ -0,0 +1,49 @@
{
"$schema": "https://raw.githubusercontent.com/kintone/js-sdk/%40kintone/plugin-manifest-validator%4010.2.0/packages/plugin-manifest-validator/manifest-schema.json",
"manifest_version": 1,
"version": 1,
"type": "APP",
"desktop": {
"js": [
"js/KintoneRestAPIClient.min.js",
"js/kuc.min.js",
"js/desktop.js"
],
"css": [
"css/51-modern-default.css",
"css/desktop.css"
]
},
"icon": "image/icon.png",
"config": {
"html": "html/config.html",
"js": [
"js/config.js"
],
"css": [
"css/51-modern-default.css",
"css/config.css"
],
"required_params": [
"buttonName"
]
},
"name": {
"en": "data fetch plugin",
"ja": "データ取得プラグイン"
},
"description": {
"en": "create search data plugin",
"ja": "検索結果のデータを生成するプラグインです"
},
"mobile": {
"js": [
"js/KintoneRestAPIClient.min.js",
"js/kuc.min.js",
"js/mobile.js"
],
"css": [
"css/mobile.css"
]
}
}