summaryrefslogtreecommitdiff
path: root/src/view/node_info.js
blob: a3b8f7d467f063af400e48bb1d06bbf7168246ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
define(['jquery', 'jquery-ui', 'view/helpers', 'view/internal'],
function($, _unused_jquery_ui,  view_helpers, internal) {

function show(d) {
    var editURL = '',
        name_field = 'Name: ' + '<input id="editformname">',
        html;

    internal.edit_tab.show('node');

    if (d.type === "third-internship-proposal") {
      html = '<br/><form id="editbox"><label>Type:</label><select id="edittype"><option value="person">Person</option><option value="club">Club</option><option value="skill">Skill</option><option value="interest">Interest</option><option value="third-internship-proposal">Third-internship-proposal</option><option value="internship">Internship</option></select><br/><label>Status</label><select id="editstatus"><option value="waiting">Waiting</option><option value="approved">Approved</option><option value="notapproved">Not Approved</option></select><br/><label>Start date:</label><input id="editstartdate"/></br><label>End date:</label><input id="editenddate"/></br><button>Save</button><button id="deletenode">Delete</button></form>';
    } else if(d.type=== "chainlink"){
      html = '<br/><form id="editbox"><button>Save</button><button id="deletenode">Delete</button></form>';
    }else{
      if (d.type !== 'skill' && d.type !== 'interest') {
        editURL = '<label>URL:</label><input id="editurl"/>'
      }
      html = '<br/><form id="editbox"><label>Type:</label><select id="edittype"><option value="person">Person</option><option value="club">Club</option><option value="skill">Skill</option><option value="interest">Interest</option><option value="third-internship-proposal">Third-internship-proposal</option><option value="internship">Internship</option></select><br/>' + editURL + '<br/><button>Save</button><button id="deletenode">Delete</button></form>';
    }

    $('.info').html(name_field + html);
    $('.info').css("border-color", view_helpers.customColor(d.type));

    $('.info').find('#editformname').val(d.name);

    $("#editenddate").datepicker({
      inline: true,
      showOtherMonths: true,
      dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
    });

    $("#editstartdate").datepicker({
      inline: true,
      showOtherMonths: true,
      dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
    });

    $('#editdescription').val(d.type);

    $('#edittype').val(d.type);

    $('#editurl').val(d.url);

    $('#editstatus').val(d.status);

    if (d.type === "third-internship-proposal") {
      $('#editstartdate').val(d.start);
      $('#editenddate').val(d.end);
    }
}

function hide()
{
    internal.edit_tab.hide();
}

function on_submit(f)
{
    internal.edit_tab.get('node', "#editbox").submit(f);
}

function on_delete(f)
{
    internal.edit_tab.get('node', "#deletenode").click(f);
}

return {
    show: show,
    hide: hide,
    on_submit: on_submit,
    on_delete: on_delete,
};

});