Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Modern UI for Office Work
Search
wtnabe
December 12, 2015
Programming
0
300
Modern UI for Office Work
Google Apps Script の HtmlService を使って Modern UI を追加する
wtnabe
December 12, 2015
Tweet
Share
More Decks by wtnabe
See All by wtnabe
Effective Jekyll
wtnabe
0
47
5 min Jekyll/Liquid Plugin cooking
wtnabe
0
22
Ruby de Wasm
wtnabe
0
46
Cloud Native Buildpacksって結局どうなの?
wtnabe
0
38
Decoupled System with Turbo Frame
wtnabe
1
120
join-kanazawarb-or-7years-passed-since-it-was-borned
wtnabe
0
770
let-me-edit-with-editor
wtnabe
0
330
google-photos-and-storage-and-rclone
wtnabe
0
440
one case of how to begin vuejs
wtnabe
2
460
Other Decks in Programming
See All in Programming
第9回 情シス転職ミートアップ 株式会社IVRy(アイブリー)の紹介
ivry_presentationmaterials
1
240
たった 1 枚の PHP ファイルで実装する MCP サーバ / MCP Server with Vanilla PHP
okashoi
1
190
型付きアクターモデルがもたらす分散シミュレーションの未来
piyo7
0
810
Go1.25からのGOMAXPROCS
kuro_kurorrr
1
800
Bytecode Manipulation 으로 생산성 높이기
bigstark
2
380
KotlinConf 2025 現地で感じたServer-Side Kotlin
n_takehata
1
230
Benchmark
sysong
0
270
Team topologies and the microservice architecture: a synergistic relationship
cer
PRO
0
1k
Railsアプリケーションと パフォーマンスチューニング ー 秒間5万リクエストの モバイルオーダーシステムを支える事例 ー Rubyセミナー 大阪
falcon8823
4
950
#kanrk08 / 公開版 PicoRubyとマイコンでの自作トレーニング計測装置を用いたワークアウトの理想と現実
bash0c7
1
440
関数型まつり2025登壇資料「関数プログラミングと再帰」
taisontsukada
2
850
0626 Findy Product Manager LT Night_高田スライド_speaker deck用
mana_takada
0
110
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Visualization
eitanlees
146
16k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.8k
Git: the NoSQL Database
bkeepers
PRO
430
65k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
930
It's Worth the Effort
3n
185
28k
Rails Girls Zürich Keynote
gr2m
94
14k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
Balancing Empowerment & Direction
lara
1
370
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.5k
Fireside Chat
paigeccino
37
3.5k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Transcript
Modern UI for Office Work @wtnabe Kanazawa.rb meetup #40 2015-12-12
(Sat) at IT-Plaza MUSASHI
お品書き 今回やりたいこと 材料 まとめ
今回やりたいこと Select2 - The jQuery replacement for select boxes
いきなりDemo
背景
Excelは便利 計算しなくても表形式のデータ管理に 別シートでマスタ管理みたいなことも 「⼊⼒規則」で <select> のようにも
便利だけれど、こういうのは困る
もう⼀度やりたいこと ⼿でデータ⼊⼒する でも正規化したい 「⼊⼒規則」は部分⼀致検索できない
それjQueryでできるよ
jQuery, jQuery-Select2 を組み込む jQuery-Select2 にデータを渡して fire $('select').select2({ data: [ {id:
1, text: '1'}, {id: 2, text: '2'} ] });
いやいやいや それHTMLの世界の話ですよね
安⼼してください
Google Spreadsheetで できますよ
材料 Google Spreadsheet Google Apps Script UiオブジェクトとMenu HtmlService Sidebar remote
scriptの実⾏ https://select2.github.io/
Google Apps Scriptの概要は 端折ります
Google Apps Scriptの 詳細を⼀部紹介します
UiオブジェクトとMenu 独⾃メニューを追加できる 新しいアクションを追加する基本 .getUi().createMenu(name) .addItem('title', funcName) .addToUi()
HtmlService Uiオブジェクトに変わる新しいUI組み⽴ て⽤のオブジェクト(出⼒は別途) Webページとして Custom Dialogとして Sidebarとして として
var html = HtmlService .createTemplateFromFile(htmlName) .evaluate() .setSandboxMode(HtmlService.SandboxMode.IFRA .setTitle(title) .setWidth(200); SpreadsheetApp.getUi().showSidebar(html);
HtmlService PHPっぽい⽂法のテンプレート <?= ?> 式は書けるけど構造化データはセットで きない(古式ゆかしい感じ) Google Apps ScriptはCSSなどのAssetは 置けないので全部CDNで
ex) https://cdnjs.com
$('select').select2({data: [ <? getOptions().map(function(e, i) { ?> {id: '<?= e
?>', text: '<?= e ?>'}, <? }); ?> ] }); ややつらい…
Custom Dialog / Sidebar Modeless UI 値を返さない 要ユーザーからの⼊⼒の扱いの設計
Remote Script & XHR google.script.run $(selector).on('click', function() { google.script.run.myFunc(value); });
XHRでremoteのfunction nameとvalueが送られる [ "myFunc", "[\"\u3044\u308d\u306f\"]", null, [0], null, true ]
remoteではSpreadsheetのアクティブなセルに⼊⼒するなど
もう⼀度Demo
まとめ GoogleApps は HTML で UI を追加できる Custom UI は
Modeless なので⼊⼒をど う扱うのか考える必要アリ google.script.run だけで remote の script を呼び出してデータを渡せる
まとめ GoogleApps は Web のノウハウが活きる しかも楽に
ハックしがいある
Enjoy Happy Hacking !