キントーンでレコード一覧から詳細画面を開く際、編集が目的のことが多いのですが、ワンクッション挟んで編集ボタンをクリックしなければなりません。そこで、詳細画面を開いたらいきなり編集モードにする方法をメモ。
考え方
通常、詳細画面を開いたとき、URLにはmode=showとなっています。詳細画面が開かれたとき、Javascriptでmode=editのページに転送します。
ソース例
PC版の場合
(function() {
'use strict';
kintone.events.on('app.record.detail.show', function(event) {
if ( location.href.match(/&mode=show/)) {
//strにmode=showを含む場合の処理
//何もしない
} else {
location.href += '&mode=edit';
}
});
})();
モバイル版の場合
(function() {
'use strict';
kintone.events.on('mobile.app.record.detail.show', function(event) {
if ( location.href.match(/#mode=show/)) {
//strにmode=showを含む場合の処理
//何もしない
} else {
location.href += '#mode=edit';
}
});
})();
