Angular Bootstrap Calendarのcustom cell templateの中にcell modifierを使用するAngularアプリで作業しています。各セルの内部では、標準的なイベントの代わりに、その日の駅でのシフトにサインするために使用される一連のテーブルを配置しています。テーブルは2つのグループに分割されています。 amとpm、各am/pmグループ内には、各テーブルに3つの行がある各ステーションのテーブルがあります。anglejsの2つのレベルで階層的にオブジェクトを整理する
am
| 1 |位置|名前|
| |ポジ1 |名前1 |
| |ポジ2 |名前2 |
| |ポジション3 |ネーム3 |
| 2 |位置|名前|
| |ポジ1 |名前1 |
| |ポジ2 |名前2 |
| |ポジション3 |ネーム3 |
pn
| 1 |位置|名前|
| |ポジ1 |名前1 |
| |ポジ2 |名前2 |
| |ポジション3 |ネーム3 |
| 2 |位置|名前|
| |ポジ1 |名前1 |
| |ポジ2 |名前2 |
| |ポジション3 |ネーム3 |私のセル変更関数の内部
、私はその日のシフトオブジェクトの配列を取得し、各シフトオブジェクトは、AMPM値とステーション値が含まれていますので、問題はそれらを取る方法です
{
"_id": "57776537ac0a88010063b9b9",
"modified": "2016-07-02T06:54:47.518Z",
"data": {
"station": "1",
"date": "2016-07-01T07:00:00.000Z",
"ampm": "pm",
"slots": [
{
"position": "AO",
"name": ""
},
{
"position": "FF",
"name": {
"_id": "57776507ac0a88010063b9b8",
"modified": "2016-07-02T06:53:59.661Z",
"data": {
"group": "suppression",
"driving": {
"n": false,
"d": true,
"ao": false,
"wt": false
},
"emtLevel": "b",
"secondaryPhoneNumber": "",
"primaryPhoneNumber": "5556781234",
"emailAddress": "[email protected]",
"fullName": "Person One",
"userName": "person.one",
"assignedStation": "18",
"probationary": false
},
"form": "57427ba554ec330100dad645",
"created": "2016-07-02T06:53:59.644Z",
"externalIds": [],
"access": [],
"roles": [
"573511a8ffaa7a0100a5718a"
],
"owner": "57776507ac0a88010063b9b8"
}
},
{
"position": "FF",
"name": {
"_id": "57439d856e67b40100d4c420",
"modified": "2016-05-24T00:17:09.493Z",
"data": {
"userName": "person.two",
"fullName": "Person Two",
"emailAddress": "[email protected]",
"primaryPhoneNumber": "5555556666",
"secondaryPhoneNumber": "",
"assignedStation": "",
"emtLevel": "b",
"driving": {
"d": true
},
"group": "suppression"
},
"form": "57427ba554ec330100dad645",
"created": "2016-05-24T00:17:09.474Z",
"externalIds": [],
"access": [],
"roles": [
"573511a8ffaa7a0100a5718a"
],
"owner": "5734bba2ffaa7a0100a57029"
}
}
]
},
をオブジェクトを作成し、上記の2つのグループに分けてテンプレートにngRepeatをループさせるだけです。私はこれまで持っていることはこれです:
vm.cellModifier = function(cell) {
cell.text = 'Test Text';
var shifts = vm.events;
// Get the date for the cell.
this.cellDate = moment(cell.date).format('YYYY-MM-DD');
// Iterate over shifts to get ones for this day.
this.cell = cell;
this.todayShifts = {};
shifts.forEach(function(shift, index, allShifts) {
var shiftDate = moment(shift.data.date).format('YYYY-MM-DD');
// Now we need to see if this shift belongs to this day.
if (moment(vm.cellDate).isSame(moment(shiftDate))) {
// Shift is today, so let's put it into the appropriate array.
if (typeof vm.todayShifts[shift.data.ampm] == 'undefined') {
vm.todayShifts[shift.data.ampm] = shift;
} else {
vm.todayShifts[shift.data.ampm].push(shift);
}
}
});
// Add arrays to cell object.
cell.todayShifts = vm.todayShifts;
};
vm.todayShifts[am]
とvm.todayShifts[pm]
を与えるが、私はまた、私はvm.todayShifts[am][1]
、vm.todayShifts[am][2]
などを持っているように、第2のレベルを取得したいと私は「何をする簡単な方法があります別のセクションのステートメントを追加するよりも、やろうとしています(私はかなり確信しています)。カスタムディレクティブやコンポーネントがクリーナーになっているのだろうかと疑問に思っています。なぜなら、そのコントローラにデータを渡すことができるからです。でも、データを正しく配置して適切な順序で表示できるようにする必要があります。
これはすべて意味があることを願っています。
ありがとうございました。